使用过滤器和/或复合过滤器的Magento 1.7肥皂要求

时间:2012-07-07 11:17:35

标签: magento soap

我正在尝试使用过滤器和使用肥皂的复杂过滤器从magento获取订单列表。以下xml-snippet显示了尚未设置参数的标准请求的结构。

Magento 1.7 使用Apache CXF的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 = '')))

显然这没有意义..没有列'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>

也许有人有解决这个问题的线索!?

提前致谢...


1 个答案:

答案 0 :(得分:2)

而不是使用“from”或“to” - 您是否尝试使用“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>