问题描述
在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 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.
这篇关于组合式复杂滤波器,适用范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!