Observer for Magent product after save

Observer for Magent product after save

August 27, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Observer for Magent product after save

Debugging Magento Product Status Update Observers: Why Your Event Isn’t Triggering

As a seasoned Magento developer, I frequently encounter issues with observers not triggering events as expected. In your case, the on_catalog_product_status_update event isn’t firing when you update a product’s status in the backend. Let’s troubleshoot this step-by-step.

Understanding the Event Configuration Issue

Firstly, let’s analyze your configuration file:

<catalog_product_status_update>
    <observers>
        <Mage4u_Customredirect_Catalog_product>
            <type>singleton</type>
            <class>mage4u_customredirect/observer</class>
            <method>on_catalog_product_status_update</method>
        </Mage4u_Customredirect_Catalog_product>
    </observers>
</catalog_product_status_update>

The issue lies in the catalog_product_status_update event. Magento doesn’t recognize this as a valid event for product status updates. The correct event name is catalog_product_save_after.

Correcting the Event Configuration

To fix this, update your configuration file:

<global>
    <events>
        <catalog_product_save_after>
            <observers>
                <Mage4u_Customredirect_Catalog_product>
                    <type>singleton</type>
                    <class>mage4u_customredirect/observer</class>
                    <method>on_catalog_product_status_update</method>
                </Mage4u_Customredirect_Catalog_product>
            </observers>
        </catalog_product_save_after>
    </events>
</global>

Replace the <catalog_product_status_update> event with <catalog_product_save_after>. This ensures your observer is triggered when a product is saved, which includes status updates.

Debugging the Observer Function

Next, let’s examine your observer function:

public function on_catalog_product_status_update(Varien_Event_Observer $observer)
{
    Mage::log("test ", null, "test");

    var_dump($observer); die();
}

The Mage::log statement is likely the cause of your issue. The on_catalog_product_status_update event doesn’t actually exist in Magento 2’s core events, which means the observer isn’t being triggered at all.

Instead, you should use the correct event name, catalog_product_save_after, and handle the product status update inside this event.

Handling Product Status Updates

To effectively manage product status updates, modify your observer function:

public function onCatalogProductSaveAfter(Varien_Event_Observer $observer)
{
    $product = $observer->getProduct();
    if ($product->hasStatusChanged()) {
        // Your code to update the product status in another server
        // Example: Mage::helper('core')->jsonEncode($product->getData());
        // ...
    }
}

In this updated function, we first retrieve the product object from the observer. We then check if the product’s status has changed using hasStatusChanged(). If the status has indeed changed, you can proceed with your logic to update the product in another server.

Conclusion: Proper Event Handling for Product Status Updates

Remember, when working with Magento observers:

  • Always verify the event name matches an actual core event.
  • Use proper naming conventions and case sensitivity.
  • Handle the specific business logic within the appropriate event context.

By updating your configuration to use catalog_product_save_after and handling the status change check inside the observer function, you should now see your product status updates triggering as expected in your external server.

For more detailed information on Magento event observers and best practices, I recommend checking out our comprehensive guide at https://laravelcompany.com/magento-event-observers.

Catalog Extensions Admin Configuration

Our network