2

Once product is created in magento , the same product details should be passed to an external source using API.

How to achieve this ?

1 Answer 1

0

You can hook and observer to the catalog_product_save_after event (just for admin scope) in the observer check if the object is new then send the data wherever you need.

Config:

{Vendor}/{Module}/etc/config.xml (part)

...
</adminhtml>
    <events>
        <catalog_product_save_after>
            <observers>
                <gps_checkout_controller_action_predispatch_checkout_onepage_saveOrder>
                    <class>{vendor}_{module}/observer</class>
                    <method>productSaveAfter</method>
                </gps_checkout_controller_action_predispatch_checkout_onepage_saveOrder>
            </observers>
        </catalog_product_save_after>
    </events>
</adminhtml>
...

Observer

{Vendor}/{Module}/Model/Observer.php

<?php
class {Vendor}/{Module}/Model/Observer 
{
    public function productSaveAfter(Varien_Event_Observer $observer)
    {
        $product = $observer->getEvent()->getData('product');
        if($product->isObjectNew()) {
            // Performe API Request ... 
        }
    }
}

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.