export products details filtered by ‘created_at’ field between two dates/timestamps using magento api


Made R&D on it and found following code can help us


$arguments = array(array('created_at'=>array('lt'=>'2011-05-25 00:00:00')));

but this is not complete solution we needed.
Afte searching hard on google finally we got some solution on following link
http://stackoverflow.com/questions/5844970/adding-filters-to-magento-web-services-api


$arguments = array(
    'created_at' => array(
        'from' => '2011-05-21 02:13:00',
        'to' => '2011-05-22 02:22:00'
    )
);

Full code can be found here

<html>
<head>
<style type="text/css">
.output_array{
    border: 1px solid #cccccc;
    margin: 10px;
}
.output_array pre{
    font-size: 12px;
}
.output_array h3{
    font-size: 14px;
    color: #ff0000;
}
</style>
</head>
<body>
<?php
$website = '172.16.0.102';
$api_login = "pk_products";
$api_key = "pk1234567";

$proxy = new SoapClient('http://'.$website.'/index.php/api/soap/?wsdl');
$sessionId = $proxy->login($api_login, $api_key);

      
     
//lt > 25
//$arguments = array(array('created_at'=>array('lt'=>'2011-05-25 00:00:00')) );   
  
  /*
$arguments = array(
array(
    'created_at'=>array('gt'=>'2011-05-23 00:00:00'),
    'created_at'=>array('lt'=>'2011-05-24 00:00:00')
    )
);
*/
                                    


  
  /*
$argument1 = array(array('created_at'=>array('lt'=>'2011-05-27 00:00:00')));   
$argument2 = array(array('created_at'=>array('gt'=>'2011-05-25 00:00:00')));   
$result1 = $proxy->call($sessionId, 'catalog_product.list', $argument1);
$result2 = $proxy->call($sessionId, 'catalog_product.list', $argument2);
$result = array_merge($result1,$result2);
  */


   
   
   $arguments = array(
    'created_at' => array(
        'from' => '2011-05-21 02:13:00',
        'to' => '2011-05-22 02:22:00'
    )
);

$result = $proxy->call($sessionId, 'catalog_product.list',array($arguments));

$count_array = count($result);
echo  "<br /><h2>".$count_array."</h2>";

echo '<pre>';
print_r($arguments);
echo '</pre>';


echo '<pre>';
print_r($result);
echo '</pre>';


?>
</body>
</html>

Share on Facebook




About Pragnesh Karia

Pragnesh Karia, Open Source Enthusiast, Software Professional, Software Developer, Technical Lead ,Magento, Joomla ,Joomla LMS , Moodel LMS ,PHP ,Mysql, Ajax, Javascript, Jquery, Linux, Fan of Open Sources , Annet Technologies , SEO Analyst , Mootools