1

I have created a function to filter products by brands as follows:

$complexFilter = array(
    'complex_filter' => array(
        array(
            'key' => 'manufacturer',
            'value' => array('key' => 'like', 'value' => $brand_id)
        ),
        array(
            'key' => 'name',
            'value' => array('key' => 'like', 'value' => '%'.$name_keyword.'%')
        )
    )
);

$result = $soapClient->catalogProductList($sessionId, $complexFilter);
var_dump ($result);

This function return correct data. but when I used category_ids in complexFilter it return me exception.

My Custom function for filter by brands and category_ids is as follows:

$complexFilter = array(
    'complex_filter' => array(
        array(
            'key' => 'category_ids',
            'value' => array('key' => 'in', 'value' => array("353"))
        ),
        array(
            'key' => 'manufacturer',
            'value' => array('key' => 'like', 'value' => $brand_id)
        )
    )
);

$result = $soapClient->catalogProductList($sessionId, $complexFilter);
var_dump ($result);

And Exception are :

{"faultstring":"Call to a member function getBackend() on a non-object","faultcode":"SOAP-ENV:Server"}

How to filter products using category_id and brand in Magento SOAP API?

  • facing the same issue here. I basically want to look for a product with a certain value for my custom attribute GTIN. Got exactly the same exception. – user32424 Oct 24 '15 at 12:42
  • Hello @Nico, you can refer my answer, I hope it is useful. – Vinaya Maheshwari Oct 26 '15 at 4:46
0

Finallly I have found my solution :

$allProductValue = (array)$soapClient->catalogCategoryAssignedProducts($sessionId, $category_id);
$result = array();
if(!empty($allProductValue))
{
    for($i = 0;$i < count($allProductValue);$i++)
    {
        $product_id = $allProductValue[$i]->product_id;
        /* get product info from product id */
        $attributes = new stdclass();
        $attributes->attributes = array('name', 'short_description', 'price');
        $attributes->additional_attributes = array('manufacturer');

        $productInfo = $soapClient->catalogProductInfo($sessionId, $product_id,'1',$attributes);
        $product_info = get_object_vars($productInfo);
        $manufacturer = get_object_vars($product_info['additional_attributes'][0]);
        if($manufacturer['value'] == $brand_id)
        {
            array_push($result,$product_info);
        }
    }
    if(!empty($result))
    {
        $returnResult = array('ProductList' => $result);
    }
    else
    {
        $returnResult = array('Message' => 'No Products founds of this brand');
    }
}
else
{
    $returnResult = array('Message' => 'No Products founds of this Category');
}
  • You can also accept your own answer ;) – sv3n Jul 10 '17 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.