Search code examples
magentoobservers

Magento - catalog_product_save_after: Check if product has been saved


I am currently trying to save a product with attributes that I have built, and it's working fine. I have also set up my code to call the catalog_product_save_after function on my observer, as shown below:

class Package_MyModule_Model_Observer
{ 
    public function catalog_product_save_after($observer)
    {
        $product = $observer->getProduct();
        //Do stuff here
    }
}

In this line of code here, is there a way to detect whether the product has already been saved (i.e. no error messages were shown)? Because I need to update some values in the database when the product is saved successfully.


Solution

  • Mostly this gets called after product is saved successfully, but to be sure you can hook into

    catalog_product_save_commit_after