When adding the product attribute, set used_in_product_listing
, used_for_sort_by
and filterable
to true
.
You can do that with the following update script:
$installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
$installer->startSetup();
$installer->updateAttribute('catalog_product', 'product_type', 'used_in_product_listing', 1);
$installer->updateAttribute('catalog_product', 'product_type', 'used_for_sort_by', 1);
$installer->updateAttribute('catalog_product', 'product_type', 'is_filterable', 1);
$installer->endSetup();
Thats all, if if you are NOT using the flat catalog.
If you enable the flat catalog product feature, then you need to ensure that your custom source model implements the methods getFlatColums()
, getFlatIndexes()
and getFlatUpdateSelect()
.
If they are missing, your attribute won't be included in the generated flat tables, even if used_in_product_listing
is enabled.
Have a look at the class Mage_Eav_Model_Entity_Attribute_Source_Boolean
for an example. You can probably copy over the methods with minimal adjustments into your custom source model from there. Otherwise, please ask a new question.
You can have different scopes for different attributes. Your attribute has obviosuly the scope "store view". Alterantives are: "store", "website" and "global".
You can change the scope with a script, but after that change, I think you have to clean up the database because magento ignores the scope while fetching the data. It only is important when writing them.
You can check this in the backend, when you view a product you can change the scope in the upper left side and beside the selectbox is the information [store view] what the scope of the attribute is.
Best Answer
Use
getStoreLabel
method.This will return you label for current store view
Or you can pass as parameter store id to get some specific label
For details look into
Mage_Eav_Model_Entity_Attribute::getStoreLabel()