Home » Magento23 December 2010

Magento: How to get / filter all products by attribute value?

Here, I will show you how you can filter or fetch products related to any particular attribute and value.

A simple scenario will be filtering products by manufacturer/brand. Suppose, I want to get all products under ‘Samsung’ manufacturer/brand.

For this, you need the attribute code and attribute value ID for which you are fetching products.

To fetch attribute name and value, you can see my previous post here:- Magento: How to get attribute name and value?

Now, lets move on to the code. Here is how you can do this:-

Hope this helps. Thanks.


Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed
  • Hello, how do I get brand/manufacturer? any code or query for this? i did this
    $products = Mage::getModel(‘catalog/product’)->getCollection();
     foreach ($products as $id => $product):
    $output .= ‘
       ‘. $product[‘entity_id’].’

    if (isset($attributes[$product[‘entity_id’]])) {
       $output .= ‘
       foreach ($attributes[$product[‘entity_id’]] as $attribute => $values)
        $output .= ‘
         ‘. $attribute .’
         ‘.  join(‘, ‘, $values) . ‘
       $output .= ‘
      $output .= ‘


  • Mahesh babu Bokkisam

    hi i have one problem

    I want to load the products which have images

    in  my appdesignfrontendmyThemedefaulttemplatecatalogproductlist.phtml

    after this i have added this code  but no luck, so what i have to do

  • Pronay Santra

    How to get product collection by category and filter by associated product attributes…

    hare is my code not working….

    $collection = Mage::getModel(‘catalog/category’)
    array(‘in’=> array(‘red’, ‘green’)),