Multiple complexFilter in Magento api v2

Im currently having some difficulties using the new Magento v2 soap from the C # interface.

With php, I managed to do something like this:

$params["created_at"]["from"] = date("Ymd H:i:s",Functions::convert_time($dataDa)); $params["created_at"]["to"] = date("Ymd H:i:s",Functions::convert_time($dataA)); MageInterface::getSingleton()->shipmentList($params); 

In this mode, I was able to find a list of orders that were created from $ dataDa to $ dataA without any problems. With C #, however, it seems that only the last of the selectors works.

My code is:

 var cpf = new complexFilter[2]; cpf[0] = new complexFilter { key = "created_at", value = new associativeEntity { key = "to", value = uxDataA.DateTime.ToString("yy-MM-dd HH:mm:ss") } }); cpf[1] = new complexFilter { key = "created_at", value = new associativeEntity { key = "from", value = uxDataDa.DateTime.ToString("yy-MM-dd HH:mm:ss") } }); var filters = new filters(); filters.complex_filter = cpf; var risultato = mage.salesOrderList(sessionKey, filters); 

In this mode, only created_at-> from the criteria is taken into account (it, as the second complex filter, overrides the previous one with the same key). Ideas?

Thanks in advance.

+1
source share
2 answers

It was decided there was an error (or a function?) In the \ sales \ order \ api \ v2.php mage

More in this thread: http://www.magentocommerce.com/boards/viewthread/70368/

0
source

This works for me:

 private filters addFilter(filters filtresIn, string key, string op, string value) { filters filtres = filtresIn; if (filtres == null) filtres = new filters(); complexFilter compfiltres = new complexFilter(); compfiltres.key = key; associativeEntity ass = new associativeEntity(); ass.key = op; ass.value = value; compfiltres.value = ass; List<complexFilter> tmpLst; if (filtres.complex_filter!=null) tmpLst = filtres.complex_filter.ToList(); else tmpLst = new List<complexFilter>(); tmpLst.Add(compfiltres); filtres.complex_filter = tmpLst.ToArray(); return filtres; } 

and call

 { Mage_Api_Model_Server_V2_HandlerPortTypeClient clientSoap = new Mage_Api_Model_Server_V2_HandlerPortTypeClient(); string sessionId = clientSoap.login(LOG, PASS); filters filtres = new filters(); filtres = addFilter(filtres, "status", "eq", "processing"); filtres = addFilter(filtres, "created_at", "from", "2014-09-07 08:00:00"); filtres = addFilter(filtres, "created_at", "to", "2014-09-07 00:00:00"); salesOrderEntity[] lst = clientSoap.salesOrderList(sessionId, filtres); } 
+4
source

Source: https://habr.com/ru/post/912000/


All Articles