Reputation: 359
i just know that if i have a product_collection (for example the collection generated in catalog pages)
//event catalog_product_collecion_after_load $productCollection = $observer->getEvent()->getCollection();
if i take an item from this collection and i compare it with the relative model $_product = Mage::getModel('catalog/product')->load($item->getEntityId());
this 2 instace of the same entity have different properties!
I'm working in flat catalog mode. Why the collection's items are not the same of product models? I would to know if this is the right behaviour and if is it how to have same properties in both object!
sorry, but magento is very dark :(
Upvotes: 0
Views: 1564
Reputation: 359
For the catalog_product_collection with flat_mode is more complicated add an attribute to the item's collection. The attributes that are in product items are the join between catalog_product_flat table and the EAV attribute for product entity.
So, in product model from:
Over these attributes we will certainly have other attributes, i think added in other point.
Now, which attributes are in catalog_product_flat? Simple are the attributes you checked as "Used in Product Listing" in magento manage attributes! :)
But in some attributes you can't change this option, depends by kind of type you have select. Atribute type Image hasn't "Used in Product Listing" flag, so you have to modify catalog_eav_attribute if you want the new image in product listing.
Well, i spent 2 days to know this, i hope it will useful for other unlucky magento developer. :)
Magento version 1.5
Upvotes: 0
Reputation: 5390
Because Mage::getModel('catalog/product')->load($item->getEntityId());
loads all attributes for the product and the collection loads only specified attributes different from situation. You may find (CTRL+F) at app/code/core/Mage/Catalog/etc/config.xml
something like attributes
then you will see the list of all default loaded attributes for product collection. Also you able to change them in your module or directly in Catalog config.xml. But it's not the best idea to change something at app/code/core/Mage/Catalog/etc/config.xml
except for debug
Upvotes: 1