限制来自 Magento SOAP 查询的结果集 [英] Limiting resultset from Magento SOAP query

查看:21
本文介绍了限制来自 Magento SOAP 查询的结果集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为 Magento SOAP 查询指定最大结果集?

How can you specify a max result set for Magento SOAP queries?

我正在通过 SOAP API 查询 Magento 以获取与给定状态匹配的订单列表.我们有一些远程主机需要很长时间才能返回列表,所以我想限制结果集,但是我没有看到这个参数.

I am querying Magento via SOAP API for a list of orders matching a given status. We have some remote hosts who are taking too long to return the list so I'd like to limit the result set however I don't see a parameter for this.

$orderListRaw = $proxy -> call ( $sessionId, 'sales_order.list', array ( array ( 'status' => array ( 'in' => $orderstatusarray ) ) ) );

我能够看到我们确实取回了数据(6 分钟后)并且能够处理超时等问题,但我更愿意只强制使用最大结果集.

I was able to see that we do get data back (6 minutes later) and have been able to deal with timeouts, etc. but would prefer to just force a max result set.

推荐答案

它似乎不能使用 limit 来完成,(另外你必须做一些复杂的分页逻辑来获取所有记录,因为你需要知道记录的总数,而 api 没有一个方法)见 api 调用列表@http://www.magentocommerce.com/api/soap/sales/salesOrder/sales_order.list.html

It doesn't seem like it can be done using limit, (plus you would have to do some complex pagination logic to get all records, because you would need know the total number of records and the api does not have a method for that) See api call list @ http://www.magentocommerce.com/api/soap/sales/salesOrder/sales_order.list.html

但是您可以做的解决方法是使用复杂的过滤器,以根据创建日期限制结果集.(根据订单量调整为每小时、每天或每周).

But what you could do as a work around is use complex filters, to limit the result set base on creation date. (adjust to ever hour, day or week base on order volume).

此外,由于您使用的是状态类型(假设您排除了更多只是取消订单),您可能需要考虑获取所有订单并在本地跟踪 order_id/status(仅处理具有上述内容的订单)状态),其余未进行的将是订单 ID 列表,稍后可能需要您注意

Also, since you are using status type (assuming that you are excluding more that just cancel order), you may want to think about getting all order and keep track of the order_id/status locally (only process the ones with the above status) and the remainder that wasn't proceed would be a list of order id that may need your attention later on

伪代码示例

$params = array(array(
        'filter' => array(
            array(
                'key' => 'status',
                'value' => array(
                    'key' => 'in',
                    'value' => $orderstatusarray,
                ),
            ),
        ),
        'complex_filter' => array(
            array(
                'key' => 'created_at',
                'value' => array(
                    'key' => 'gteq',
                    'value' => '2012-11-25 12:00:00'
                ),
            ),
            array(
                'key' => 'created_at',
                'value' => array(
                    'key' => 'lteq',
                    'value' => '2012-11-26 11:59:59'
                ),
            ),
        )
    ));

    $orderListRaw = $proxy -> call ( $sessionId, 'sales_order.list', $params);

阅读更多关于过滤@http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-8-varien-data-collections

这篇关于限制来自 Magento SOAP 查询的结果集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆