0

I have created a multi select attribute and assigned this to attribute set. Attribute is showing in product search results but I am unable to include this into product collection filtering as well as into addAttributeToSelct Here is the section I am using this attribute to filter the prodcut collection.

$collection = Mage::getModel("catalog/product")
            ->getCollection()
            ->addAttributeToSelect(array('sku','speciality','name'))
            ->addFieldToFilter('speciality', array('eq' => $speciality));
echo $collection->getSelect();

And in my browser I have the following result for select query

SELECT `e`.`entity_id`, `e`.`type_id`, `e`.`attribute_set_id`, `e`.`sku`, `e`.`name` FROM `catalog_product_flat_3` AS `e` WHERE (e.status = 1)

Here are screen shot for the attribute configuration enter image description here enter image description here

0

At first look, I see two points that could help you :

1) It seems that you are using the flat_catalog feature. And, as your attribute speciality is set to be Used in product listing, you have to reindex product_flat index before to be able to retrieve it in your collection.

2) I think you should use addAttributeToFilter instead of addFieldToFilter too.

  • Thanks @julien-loizelet, I was using flat_catalog on my store so by re-indexing the problem was solved. – Muhammad Shahbaz Mar 19 '18 at 16:29
  • Thanks. If you think it is a correct answer, please mark my answer as accepted answer : it may help future users. – Julien Loizelet Mar 19 '18 at 17:34

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.