Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
884 views
in Technique[技术] by (71.8m points)

web services - Combined complex filter for ranges

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')
    ), 
);

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.

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I found a better way looking at the code in Magento! Luckily it IS CASE SENSITIVE, so:

$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')
    ), 
);

does the trick pretty neatly!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...