1

I have observer for a hook catalog_product_save_commit_after with following XML config

<events>
    <catalog_product_save_commit_after>
        <observers>
            <mymodule_catalog_product_save_commit_after>
                <type>singleton</type>
                <class>My_Module_Model_Observer</class>
                <method>sendProductUpdate</method>
            </mymodule_catalog_product_save_commit_after>
        </observers>
    </catalog_product_save_commit_after>
    ...

I'm sending the product url via API to another service. When user changes the URL key in Magento's catalog product edit view I'm always getting URL containing the outdated URL Key in my observer.

Example:

Store url is http://notarealstore-just-an-example.com/ and I change a product's URL key from linen-blazer (product url being http://notarealstore-just-an-example.com/linen-blazer.html) to cotton-blazer. You would expect the product url to be changed to http://notarealstore-just-an-example.com/cotton-blazer.html. However I'm still getting http://notarealstore-just-an-example.com/linen-blazer.html as a product url in my observer. When I update the product again without changing the url key I get the URL correctly (http://notarealstore-just-an-example.com/cotton-blazer.html).

In short it seems the catalog_product_save_commit_after is fired before the product URLs are saved.

I'm using this method to fetch the product url

/* @var Mage_Catalog_Model_Product $product */
$product_url = $product->getUrlInStore(
    array(
        '_nosid' => true,
        '_ignore_category' => true,
        '_store' => 1,
    )
);

Any idea how to get the correct (updated) product url.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.