2012-07-07 107 views
0

我想從magento使用過濾器和複雜的過濾器通過使用肥皂的訂單列表。以下xml-snippet顯示了尚未設置參數的標準請求的結構。使用Apache CXF 有數據庫項目Magento 1.7 soap請求使用過濾器和/或複雜的過濾器

Magento的1.7 SOAP客戶端...


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Magento"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <urn:salesOrderListRequestParam> 
     <sessionId>?</sessionId> 
     <filters> 
      <!--Optional:--> 
      <filter> 
       <!--Zero or more repetitions:--> 
       <complexObjectArray> 
        <key>?</key> 
        <value>?</value> 
       </complexObjectArray> 
      </filter> 
      <!--Optional:--> 
      <complex_filter> 
       <!--Zero or more repetitions:--> 
       <complexObjectArray> 
        <key>?</key> 
        <value> 
        <key>?</key> 
        <value>?</value> 
        </value> 
       </complexObjectArray> 
      </complex_filter> 
     </filters> 
     </urn:salesOrderListRequestParam> 
    </soapenv:Body> 
</soapenv:Envelope> 

我嘗試使用這個請求,一個過濾器調用API,這樣:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Magento"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <urn:salesOrderListRequestParam> 
     <sessionId>02ec011a4deef70a55104d8b229e0d41</sessionId> 
     <filters> 
      <!--Optional:--> 
      <filter> 
       <!--Zero or more repetitions:--> 
       <complexObjectArray> 
        <key>customer_lastname</key> 
        <value>cook</value> 
       </complexObjectArray> 
      </filter> 
      <!--Optional:--> 
      <complex_filter> 
       <!--Zero or more repetitions:--> 
      </complex_filter> 
     </filters> 
     </urn:salesOrderListRequestParam> 
    </soapenv:Body> 
</soapenv:Envelope> 

答覆保留了我希望的數據,庫克先生的訂單清單。到現在爲止還挺好。

現在享受了這個偉大的成功(;-))我試圖進入下一個層次。在這種情況下,我嘗試發送更多標準來聚合所需的數據並從數據庫中獲取。

因此,我試圖查找到某個日期創建的所有訂單。以下XML顯示這種類型的請求:


<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
     <ns2:salesOrderListRequestParam 
      xmlns:ns2="urn:Magento"> 
      <sessionId>2b15208c5153189ed7477750c177716c</sessionId> 
      <filters> 
       <complex_filter> 
        <complexObjectArray> 
         <key>created_at</key> 
         <value> 
          <key>from</key> 
          <value>2012-07-06 12:55:51</value> 
         </value> 
        </complexObjectArray> 
       </complex_filter> 
      </filters> 
     </ns2:salesOrderListRequestParam> 
    </soap:Body> 
</soap:Envelope> 

事實上這個請求在數據庫中創建一個錯誤。下面是Magento的創建聲明:

SELECT `main_table`.*, `billing_o_a`.`firstname`, `billing_o_a`.`lastname`, `billing_o_a`.`telephone`, `billing_o_a`.`postcode`, `shipping_o_a`.`firstname`, `shipping_o_a`.`lastname`, `shipping_o_a`.`telephone`, `shipping_o_a`.`postcode`, `billing_o_a`.`firstname` AS `billing_firstname`, `billing_o_a`.`lastname` AS `billing_lastname`, `shipping_o_a`.`firstname` AS `shipping_firstname`, `shipping_o_a`.`lastname` AS `shipping_lastname`, CONCAT(billing_o_a.firstname, ' ', billing_o_a.lastname) AS `billing_name`, CONCAT(shipping_o_a.firstname, " ", shipping_o_a.lastname) AS `shipping_name` FROM `mage_sales_flat_order` AS `main_table` 
LEFT JOIN `mage_sales_flat_order_address` AS `billing_o_a` ON (main_table.entity_id = billing_o_a.parent_id AND billing_o_a.address_type = 'billing') 
LEFT JOIN `mage_sales_flat_order_address` AS `shipping_o_a` ON (main_table.entity_id = shipping_o_a.parent_id AND shipping_o_a.address_type = 'shipping') WHERE (((from = ''))) 

顯然,這是沒有意義的..有沒有「從」列,其中是發送日期隱藏,爲什麼

... WHERE(((從= '')))

<complexObjectArray> 
    <key>created_at</key> 
    <value> 
    <key>from</key> 
    <value>2012-07-06 12:55:51</value> 
    </value> 
<complexObjectArray> 

異常 'Zend_Db_Statement_Exception' 有消息「SQLSTATE [42000]:語法錯誤或訪問衝突:1064您的SQL語法錯誤;請檢查與您的MySQL服務器版本對應的手冊,以便在/home/.../public_dev/lib/Zend/Db/Statement/Pdo中的'from ='')))'第3行'附近使用正確的語法。 PHP:234

好東西放在這裏可怕的錯誤...

下面是Magento的頁面的示例代碼片段:

<item xsi:type="ns1:complexFilter"> 
    <key xsi:type="xsd:string">protect_code</key> 
    <value xsi:type="ns1:associativeEntity"> 
     <key xsi:type="xsd:string">in</key> 
     <value xsi:type="xsd:string">a4ffa8</value> 
    </value> 
</item> 

也許有人有線索來解決這個問題!?

在此先感謝...


+0

顯然這似乎是magento的v2 API中的一個bug – stereoscope 2012-07-13 15:14:04

回答

2

而不是使用 「從」 或 「到」 - 你嘗試使用 「gteq」 和 「lteq」 呢?當使用PHP進行測試時,然而你不能提供一個上限和下限,例如,

<complexObjectArray> 
    <item> 
    <key>created_at</key> 
    <value> 
    <key>gteq</key> 
    <value>2012-07-06 12:55:51</value> 
    </value> 
    </item> 
    <item> 
    <key>created_at</key> 
    <value> 
    <key>lteq</key> 
    <value>2013-07-06 12:55:51</value> 
    </value> 
    </item> 
<complexObjectArray>