0

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

Magento 1.7 Soap 客户端使用 Apache CXF 数据库中有项目...


<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 = '')))

显然这没有任何意义..没有“来自”列,发送日期隐藏在哪里以及为什么

...在哪里(((来自='')))

<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 的第 3 行的“from = '')))' 附近使用正确的语法。 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>

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

提前致谢...


4

1 回答 1

3

而不是使用“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>
于 2013-12-10T18:07:45.650 回答