Question

I'm using Magento soap API for a mobile app and in my app I need to get products which are under a certain category and are also filtered by brand.

it is possible to get the products assigned to a category by calling catalog_category.assignedProducts but this method doesn't allow filtering by other attributes.

on the other hand we have the catalog_product.list method which can filter products by attributes but I think it can't filter products by category.

is there any way to filter products by both category and brand (an attribute)?

Was it helpful?

Solution

I ended up using foreach method to manually filter the result of catalog_category.assignedProducts method like this:

$products = $client->call($session, 'catalog_category.assignedProducts',$categoryId);
if($brandId!=null && $brandId>0)
{
    $result=array();
    foreach ($products as $product) {
        if($product['brand']==$brandId)
            array_push($result,$product);
    }
}
else{
    $result=$products;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top