Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Magento API help needed
 
Jelmo
Jr. Member
 
Total Posts:  28
Joined:  2008-08-15
 

Hi,

I’m trying to use the Magento API for some things on my Magento site. But i’ve run into some problems which may be preceived as n00b, but i’m still gonna ask anyway wink

After i log into the api i want to get a listing of all the products with a certain attribute. I’m trying to use the “catalog_product.list” function and want to refine the list based on an attribute. This attribute is called featured_2 and featured_5.

So far, i’ve tried the following which all did nothing:

$catalogTree $client->call('call', array($session'catalog_product.list', array('featured_2''1')));
$catalogTree $client->call('call', array($session'catalog_product.list', array('featured_2' => '1')));

and from the api examples copied

try {
    $filters 
= array(
        
'featured_2' => array('is'=>'1')
     );
    
$catalogTree $client->call($session'product.list', array($filters));
    OR
    
$catalogTree $client->call($session'catalog_product.list', array($filters));

What am i doing wrong ? anyone with experience on this field ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
cgalpin
Jr. Member
 
Total Posts:  11
Joined:  2008-06-25
 

Assuming you have products with a value of 1, those should work. Try a filter of

$filters = array(
        
'featured_2' => array('='=>'1')
     );

And if that doesn’t work, try without a filter first and verify the field names and values on the products that you get back.

hth
charles

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jelmo
Jr. Member
 
Total Posts:  28
Joined:  2008-08-15
 

Thanks for the reply, i’ll look into it tomorrow !

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jelmo
Jr. Member
 
Total Posts:  28
Joined:  2008-08-15
 

I see what the problem is,

The item list that i’m trying to sort doesn’t have the featured information. Only a more detailed call to catalog_product.info will return this info.

But i tried this option, First getting all the products in the webshop and then modifying the array with all the product so only the items with “Featured_2” or “Featured_5” remain, but this is inmensly slow ...

any beter way to get all the products marked by this attribute without getting alle the products at once and going over all of them find the appropriate ones ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jelmo
Jr. Member
 
Total Posts:  28
Joined:  2008-08-15
 

Well i sort of found an workaround which is easier for the store owner.

I create a store category that is hidden, and with the API i select all products from this (much smaller) category. This way the store owner can add more products then that are shown, so they will change.

 
Magento Community Magento Community
Magento Community
Magento Community
 
cgalpin
Jr. Member
 
Total Posts:  11
Joined:  2008-06-25
 

Yeah that sounds like a very pragmatic way of handling it. I’d open a bug report (or feature request) for this kind of filtering to be added to the API though.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top