Search code examples
phpmagentomagento-soap-api

Magento API v2 filter by custom attribute


I've been looking all over the web but I can't seem to find any examples and I've tried it but failed. I am using version 2 of the api and I want to find product that filters by a customer attribute like so...

$filter = array(
        array(
            'key'=>'custom_attribute',
            'value'=>"463"
        )
);
$products = $client->catalogProductList($session,array(
    'filter'=>$filter
)); 

But I am getting all the products and not the specific product I am looking for. Is there anything I am doing wrong ? Is there anything I am missing ??


Solution

  • Try following code.

    $complexFilter = array (
        'complex_filter' => array(
            array(
            'key' => 'custom_attribute',
                'value' => array(
                    'key' => 'eq', 
                    'value' => '463'
                )
            )
        )
    );
    $products = $client->catalogProductList($session, $complexFilter);