1

I'm looking to trigger anything on a /admin/customer/edit just to know it's working.. an echo or print.. I have this code below.

app/code/community/YourModule/etc/config.xml

<global>
<events>                
    <customer_address_save_before>
        <observers>
            <yourmodule>
                <type>singleton</type>
                <class>yourmodule/observer</class>
                <method>customer_address_save_before</method>
            </yourmodule>
        </observers>
    </customer_address_save_before>

    <customer_address_save_after>
        <observers>
            <yourmodule>
                <type>singleton</type>
                <class>yourmodule/observer</class>
                <method>customer_address_save_after</method>
            </yourmodule>
        </observers>
    </customer_address_save_after>

    <catalog_product_save_before>
        <observers>
            <yourmodule>
                <type>singleton</type>
                <class>yourmodule/observer</class>
                <method>catalog_product_save_before</method>
            </yourmodule>
        </observers>
    </catalog_product_save_before>

    <catalog_product_save_after>
        <observers>
            <yourmodule>
                <type>singleton</type>
                <class>yourmodule/observer</class>
                <method>catalog_product_save_after</method>
            </yourmodule>
        </observers>
    </catalog_product_save_after>       
</events>

My Observer:

app/code/community/YourModule/

class YourNamespace_YourModule_Model_Observer
{   
    public function customer_address_save_before($observer)
    {
        $address = $observer->getCustomerAddress();
        //echo "<pre>"; print_r($address->getData()); exit;
        // do something here
    }

    public function customer_address_save_after($observer)
    {
        $address = $observer->getCustomerAddress();     
        //echo "<pre>"; print_r($address->getData()); exit;
        // do something here
    }

    public function catalog_product_save_before($observer)
    {
        $product = $observer->getProduct();     
        //echo "<pre>"; print_r($product->getData()); exit;
        // do something here
    }

    public function catalog_product_save_after($observer)
    {
        $product = $observer->getProduct();     
        //echo "<pre>"; print_r($product->getData()); exit;
        // do something here
    }
}

Now in admin how would i get it to echo something on /admin/customer/edit or any page for that matter if an address is updated.

I'd assume something like so:

  $t = Mage::getModel('yourmodule/observer');

Mage::getSingleton??

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.