Magento – Struggling with Observer rewrite (not conflicts that I can find)

event-observermagento-1.9modeloverrides

I am trying to rewrite an observer in the extensions Xtento_GridActions. The observer is established this way:

        <core_block_abstract_prepare_layout_after>
            <observers>
                <addMassactionsToGrid>
                    <type>model</type>
                    <class>Xtento_GridActions_Model_Observer</class>
                    <method>core_block_abstract_prepare_layout_after</method>
                </addMassactionsToGrid>
            </observers>
        </core_block_abstract_prepare_layout_after>

I have created my rewrite class at app/code/local/Mymod/Orders/Model/Xtentorewrite/Observer.php and it looks like this:

class Mymod_Orders_Model_Xtentorewrite_Observer extends Xtento_GridActions_Model_Observer {

    /*
     * Get controller names where the module is supposed to modify the block
     */
    public function getControllerNames()
    {
        die('here');
        $originalArray=array('order', 'sales_order', 'adminhtml_sales_order', 'admin_sales_order', 'orderspro_order');
        $newOrdersController="orders"; 
        $modifiedArray=$originalArray;
        $modifiedArray[]=$newOrdersController;
        return $modifiedArray;
    }
}

My config.xml looks like this

 <?xml version="1.0"?>
 <config>
<modules>
    <Mymod_Orders>
        <version>0.1.5</version>
    </Mymod_Orders>
</modules>
<global>
    <models>
        <mymodorders>
            <class>Mymod_Orders_Model</class>
        </mymodorders>
        <xtento_gridactions>
            <rewrite>
                <observer>Mymod_Orders_Model_Xtentorewrite_Observer</observer>
            </rewrite>
        </xtento_gridactions>
    </models>
    <blocks>
        <orders>
            <class>Mymod_Orders_Block</class>
        </orders>
    </blocks>
</global>
<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <Mymod_Orders before="Mage_Adminhtml">Mymod_Orders</Mymod_Orders>
                </modules>
            </args>
        </adminhtml>
    </routers>

</admin>
<crontab>
    <jobs>
        <Mymod_Fetch_Unpaid_Orders_Report>
            <schedule>
                <cron_expr>0 5 * * 1,2,3,4,5</cron_expr>
                <!-- Run on weekdays (1-5) at 5 am -->
            </schedule>
            <run>
                <model>mymodorders/fetchorderinfo::mailReport</model>
            </run>
        </Mymod_Fetch_Unpaid_Orders_Report>
    </jobs>
</crontab>

Best Answer

You can override observers easily.

In your own module add this to your config xml events area

    <core_block_abstract_prepare_layout_after>
        <observers>
            <addMassactionsToGrid>
                <type>model</type>
                <class>mymod_orders/xtentorewrite_observer</class>
                <method>core_block_abstract_prepare_layout_after</method>
            </addMassactionsToGrid>
        </observers>
    </core_block_abstract_prepare_layout_after>

It might be worthwhile reading through this: http://www.atwix.com/magento/overriding-observers/

Also, you can see that you should not give the full class name. Give the magento alias!

Related Topic