Frage

I've created a custom attribute for some products in magento. I set "Used In Product Listing" to true and reindexed product flat data. When i do select * from catalog_product_flat_19 (19 being the id of my store) i see the column and i can update its values in the extranet. But when i do

foreach($quote->getAllItems() as $product) 
    var_dump($product->getMyCustomAttribute()); //this retuns null

I turned on mysql debugging and i see a select from catalog_product_flat_19, but its specifying specific columns and my custom attribute isnt one of them. Can anyone tell me what i need to do to add it there?

To be more specific, i'm trying to access the attribute in an observer thats watching the sales_order_save_commit_after event that happens in an ajax request.

Thanks for your help in advance.

War es hilfreich?

Lösung

This, like all things in magento, turns out to be a configuration thing. In Mage/Sales/etc/config.xml there is a config/global/sales/quote/item/product_attributes node. That node contains a list of all the columns the flat table should return. If you add that XML path to your config file for whatever module you are creating and add an empty node to it named the column you want to bring back. It will work.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top