I have rewrited Api model of Magento Core (M1.9) and want to test how it works. It returns too may records and I want to set conditions like in Sql “order BY Desc|Asc” and “LIMIT” in my tests. But i dont know where should i place mentioned conditions.
Here is my code for tests:
$username = 'testapi';
$apikey= 'password';
$client = new Zend_XMLRPC_Client('https://www.magentohost.com/index.php/api/xmlrpc');
$session = $client->call('login', array($username, $apikey));
$filters = array(
array(
'category_id' => 163,
'internal_rating' => 6
//array('product_id'=>'Order by ASC')
));
try {
$message = $client->call('call', array($session, 'catalog_product.list', $filters));
var_dump($message);
} catch (Exception $fault) {
echo $fault->getMessage();
}
I will be appreciated for any advice
3
Answers
I tried to transfer the parameters limit,dir, order into url request by GET method like:
And in rewrited class Mage_Catalog_Model_Product_Api method item
And it gave googd tests.It is similar Solution as HAKIM suggested.
Please, try to test the code below:
I haven’t tested it by myself. I took the format of filter parameters from the link http://devdocs.magento.com/guides/m1x/api/rest/get_filters.html
Maybe it will work for your case, too.
You have to rewrite this class and override items function
class = Mage_Catalog_Model_Product_Api
function = items
then you can call it by