I'm updating product stock inventory attribute programactically. Considering performance, instead of saving whole product, I'm saving quantity attribute only.

    //  $quantity value
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
$mainCurrQty = $stock->getQty();

At the same time I want to call catalog_product_save_after observer which is not working as it's not saving the product and saving the attribute value only. How I can call catalog_product_save_after observer when only a particular attribute value is updated programatically?

1 Answer 1


Dispatch the event yourself with the same data as Magento does in save():

Mage::dispatchEvent('catalog_product_save_after', array(
    'data_object' => $_product,
    'product' => $_product)
  • 1
    This is dangerous. If the $_product is not fully loaded (it comes form a collection) it may result in loss of data
    – Marius
    Jul 22, 2015 at 8:02
  • I agree that there might be observers that rely on a fully loaded product and don't behave as expected. Loss of data is the worst case, of course, but does not happen per se. Jul 22, 2015 at 8:09
  • 1
    True. It depends on what the observers for that event do. But it's something that should be kept in mind.
    – Marius
    Jul 22, 2015 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.