Home » Magento15 April 2013

Magento: Unable to select custom attribute on product collection

Problem:

I had added a new product attribute. Suppose the attribute code is ‘test’. I have been trying to fetch/select that newly added product attribute. Here is my Magento collection code:-

I don’t see the attribute ‘test’ when I print the collection data.

Cause:

The attribute is not fetched because my shop had ‘Product Flat Data’ enabled. And the attribute is not included in the Flat Product Index.

Solution:

To include the attribute (our attribute code is ‘test’) in flat index, we need to add the following code in config.xml file of your custom module:

After that, we need to reindex Product Flat Data.

– Login to Admin
– Go to System -> Index Management
– Reindex ‘Product Flat Data

Now, the above collection code should be able to select your custom attribute ‘test‘.

Thanks to Ivan Chepurnyi for the solution over here: http://stackoverflow.com/a/11798502/327862

Hope it helps. Thanks.

Magento

Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed
  • Magento Developer

    Another way is to load the product by id in the loop and get the data.