I'm trying to get custom product attribute value (for attribute code flr01
) in catalog_product_save_after
observer without loading the product but I'm gettin null value if I'm not loading the product before using following functions
$qty = $observer->getProduct()->getAttributeText('flr01');
or
$qty = $observer->getProduct()->getData('flr01');
While loading the product before using getData()
method, I'm getting flr01
value
$productId = $observer->getProduct()->getId();
$product = Mage::getSingleton('catalog/product')->load($productId);
$qty = $product->getData('flr01');
I think loading the product again is not recommended from performance point of view (I should already have all product attributes available in $observer->getProduct()
).
Best Answer
You can get custom attribute data using below code at observer
and for getting : text value if it dropdown.