我正在将Magento V1.82升级到Magento 2.2。 目前,我将Magento SOAP API接口与MSSQL结合使用,这是一种过时的方法,并且希望探索最新的方法。因此,我想知道在Magento与MSSQL之间进行交互的最佳方法是什么。
我在node.js上有经验,想探索是否有人建议。
当前SOAP API接口伪代码:
Module1.vb
模块Module1
Public sOutputPath As String = AppDomain.CurrentDomain.BaseDirectory & "Output\"
Public sArcPath As String = AppDomain.CurrentDomain.BaseDirectory & "Arc\"
Public sInputPath As String = AppDomain.CurrentDomain.BaseDirectory
Public URL As String = "https://www.example.com/store/index.php/api/v2_soap/index/"
获取会话ID
Function getSessionID() As String
Dim sRequestFileName As String = sInputPath & "login.txt"
Dim sRequestContent As String = GetFileContent(sRequestFileName)
Dim sOutputFileName As String = "sessionID.txt"
Dim fPost As Boolean = False
fPost = PostRequest(sRequestContent, URL, sOutputFileName)
If fPost Then
sRequestContent = GetFileContent(sOutputPath & sOutputFileName)
Dim xmldoc As System.Xml.XmlDocument = New System.Xml.XmlDocument
Try
xmldoc.LoadXml(sRequestContent)
Catch ex As Exception
Return ""
End Try
Dim nsMgr As System.Xml.XmlNamespaceManager = New System.Xml.XmlNamespaceManager(xmldoc.NameTable)
nsMgr.AddNamespace("SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/")
nsMgr.AddNamespace("ns1", "urn:Magento")
nsMgr.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance")
nsMgr.AddNamespace("SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/")
getSessionID = xmldoc.SelectSingleNode("/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:loginResponse/result", nsMgr).InnerText
获取订单列表:
getListOfOrd = False
Dim sRequestFileName As String = sInputPath & "req_ListOfOrd_Processing.txt"
Dim sRequestContent As String = GetFileContent(sRequestFileName)
Dim sOutputFileName As String = "_ListOfOrd.txt"
sRequestContent = Replace(sRequestContent, "**sessionID**", sSessionID)
Debug.Print(sRequestContent)
Dim fPost As Boolean = False
fPost = PostRequest(sRequestContent, URL, sOutputFileName)
If fPost Then
sRequestContent = GetFileContent(sOutputPath & sOutputFileName)
Dim xmldoc As System.Xml.XmlDocument = New System.Xml.XmlDocument
Try
xmldoc.LoadXml(sRequestContent)
Catch ex As Exception
Return ""
End Try
Dim nsMgr As System.Xml.XmlNamespaceManager = New System.Xml.XmlNamespaceManager(xmldoc.NameTable)
nsMgr.AddNamespace("SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/")
nsMgr.AddNamespace("ns1", "urn:Magento")
nsMgr.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance")
nsMgr.AddNamespace("SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/")
getSessionID = xmldoc.SelectSingleNode("/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:loginResponse/loginReturn", nsMgr).InnerText
Dim nl As System.Xml.XmlNodeList
Dim sOrderNumber As String
Dim iArrLen As Integer
nl = xmldoc.SelectNodes("/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:salesListOfOrdResponseParam/result/complexObjectArray/increment_id", nsMgr)
If nl.Count > 0 Then
.
.
.
Get the order...