范围的组合复杂过滤器 [英] Combined complex filter for ranges

查看:35
本文介绍了范围的组合复杂过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Magento 1.7 SOAP APIv2 上,我正在寻找一种方法来获取日期范围以从 SOAP API 检索信息.

On Magento 1.7 SOAP APIv2, i'm looking for a way to get a date range to retrieve information from the SOAP API.

$complexFilter = new filters();
$complexFilter->complex_filter = array(
    array(
        'key' => 'created_at',
        'value' => array('key' => 'from', 'value' => '2012-12-17 00:00:00')
    ), 
    array(
        'key' => 'created_at',
        'value' => array('key' => 'to', 'value' => '2013-01-21 12:02:02')
    ), 
);

这似乎是最自然的方法,但只使用了最后一个标准.我还尝试了其他组合,例如复杂过滤器的复杂过滤器,组合它们的不同方法,使用 gt 等代替 from 和 co.这些方法中的大多数都产生了相同的结果:只会使用里面的最后一个标准.

This seemed like the most natural approach, but only the last criterion gets used. I also tried other combinations like a complex filter of complex filters, different ways to combine them, using gt and alike instead of from and co. Most of these approaches resulted in the same result: only the last criterion inside will be used.

通过 API 获取日期范围的正确方法是什么?这也可以通过常规过滤器完成吗?如果是这样,如何组合开始和结束日期?

What is the proper way to get a date range via the API? Can this also be done via a regular filter? If so, how to combine the start and end date?

推荐答案

在谷歌搜索了很多之后我终于来了 一些解释.

After googling a lot more i finally come to some explanation.

显然,复杂过滤器的实现不允许存在多个属性.这也是我在测试中注意到的:只有最后使用的属性会影响结果.因此,我需要找到另一种方式来做我想做的事.看到 Magento 没有提供一种简单的方法来使用 SOAP API 做到这一点,我感到有些遗憾.

Obviously, the implementation of the complex filters does not allow more then one attribute to be present. This is also what I noticed during my tests: only the last attribute used influences the result. I therefore need to find another way of doing what I want. It's somehow sad to see that Magento does not provide an easy way to do this with ther SOAP API.

我现在使用的最后一种方法是确定一个最接近我想要的日期.然后只需遍历我想要的日期范围内的结果.通过这种方式(至少对于我们的产品数据),我将负载和结果保持在最低限度,并且仍然可以获得所需的产品.

The final approach I used now is to determine a date that comes closest to what I want. Then just iterate through the results that that are in the daterange I want. This way (at least with our product data), I keep the load and results to a minumum and still get the desired products.

edit 似乎原始链接已关闭并且该站点不再存在.上面的文字应该是足够的信息.该博客仅展示了一些错误实现的代码示例.

edit seems like the original link is down and the site doesn't exist anymore. The text above should be enough information. The blog merely showed some code examples with the faulty implementation.

这篇关于范围的组合复杂过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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