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.
To answer the question:
Thanks to some handy built-in methods you don't have to do any loading on your own:
Mage_Sales_Model_Order_Shipment_Item
provides getOrderItem
Mage_Sales_Model_Order_Item
provides getProduct
So, all you should have to do is this:
$product = $shipmentItem->getOrderItem()->getProduct();
If size
is persisted to the order item, you can do:
$item = $shipmentItem->getOrderItem();
echo $item->getAttributeText('size');
Or, if you need to load the ID value from the product itself, you can get all of the product's selected ID values:
$size = $shipmentItem->getOrderItem()->getProduct()->getSize();
Best Answer
Hi you can do this by
updateAttribute
() functionCreate
upgrade installer
and on the upgrade file update field by updateAttribute() function.Here
format:
Till now ,i cannot find the where the issue But currently, i give u an alternative solution: