LucScu
LucScu

Reputation: 359

magento - how to add property to eav model when is inialized

i'm not able to add a property in _data array() to EAV model (extended Product Model) when it is initialized, for example by a collection call (Mage::getResourceModel('catalog/product_collection')).

I try to extend _construct() with setValue(), but not work and here _data is empty!

When _data is filled?

When i have the product model with _data setted and i can manipulate this in initialization phase?

I don't want an attribute setted in db, because this attribute is dynamic.

thx for replies! :)

Upvotes: 0

Views: 273

Answers (2)

barbazul
barbazul

Reputation: 618

What attributes are loaded and when are they loaded depends on where are you "standing" and whether or not you have the flat catalog enabled.

Generally speaking, to have an attribute loaded into a catalog/product_collection you need to specify it like this:

<?php
$collection = Mage::getResourceModel('catalog/product_collection')->addAttributeToSelect('my_custom_attribute')

Upvotes: 0

Tim Bezhashvyly
Tim Bezhashvyly

Reputation: 9100

You can always do it in the _load_after observer.

Upvotes: 1

Related Questions