2

I want to display all the product with some product attribute features.

ie; I have 3 products in kids category with attributes and categories like

Category: boy and girl

Size: small, medium,large

color: black,red,white

so I need all the product having Category->boy, Size->small,medium,&color->black,white.

How can it be done?

0

Use below code to filter product collection

$_productCollection = Mage::getModel('catalog/product')
                ->getCollection()
                ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
                ->addAttributeToSelect('*')
                ->addAttributeToFilter('category_id','your-category-id')
                ->addFieldToFilter('size',
                    array(
                        array('eq'=> 'small'),
                        array('eq'=> 'medium')
                    )
                )
                ->addFieldToFilter('color',
                    array(
                        array('eq'=> 'black'),
                        array('eq'=> 'white')
                    )
                );

Hope it will be helpful to you.

  • your code is not working – Sourav Mar 18 '16 at 19:17
  • not getting the products. – Shafeeque S Mar 19 '16 at 7:09

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.