2009-12-17 43 views
1

目前,我在使用新的Magento的soap v2從c#界面上遇到一些困難。Magento api v2中的多個complexFilter

用PHP我能夠做這樣的事:

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

在這種模式下我能找到這是從$ dataDa至$數據A創建沒有問題的訂單列表。但是,用c#似乎只有最後一個選擇器才起作用。

我的代碼:

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); 

在這種模式下只有created_at->從標準被取入考慮(它像第二複數濾波器覆蓋以前一個具有相同的鍵)。想法?

在此先感謝。

回答

0

解決,有在法師\銷售是一個錯誤\命令\ API \ v2.php

見在此線程的詳細信息(或功能):http://www.magentocommerce.com/boards/viewthread/70368/

+3

,因爲我是運行到同樣的問題,那將是非常巨大的,如果你w ^請節省我一些時間,並解釋你的經歷以及如何爲你解決它:)謝謝 – dasheddot 2012-03-01 15:52:39

+0

SOrry,我錯過了你的回覆。看看這個討論:http://www.magentocommerce.com/boards/viewthread/70368/ – Alekc 2012-04-06 19:32:28

4

這個工作對我來說:

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; 
    } 

,並呼籲

{ 
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); 
} 
+0

這addFilter方法是一個很好的功能,我會用它在我的軸生成的代碼:-) – runholen 2014-10-15 07:21:10