I am using an extension which adds an order action to sales->orders by using an observer for when the event building it fires. I noticed this wasn't working and this is because another extension modifies the sales->orders (if I disable that extension then the first extension adds to the actions fine) but what I do not understand is I feel it should work anyway because the second extension should extend magento's core classes so the event that the observer is ties to should still fire and the logic inside the first extension which handles the observer should still evaluate to true and add the order action? I was wondering if any of you could see an error that would cause the observer not to fire or the logic inside the observer not to evaluate the way I want it to.
The relevant config.xml of the first extension is:
<core_block_abstract_prepare_layout_before>
<observers>
<monkey_order_addmassbutton>
<class>monkey/observer</class>
<method>massActionOption</method>
</monkey_order_addmassbutton>
</observers>
</core_block_abstract_prepare_layout_before>
the massActionOption observer is:
public function massActionOption(Varien_Event_Observer $observer)
{
if (!Mage::helper('monkey')->canMonkey()) {
return $observer;
}
$block = $observer->getEvent()->getBlock();
if ($block instanceof Mage_Adminhtml_Block_Widget_Grid_Massaction || $block instanceof Enterprise_SalesArchive_Block_Adminhtml_Sales_Order_Grid_Massaction) {
if ($block->getRequest()->getControllerName() == 'sales_order') {
$block->addItem('magemonkey_ecommerce360', array(
'label' => Mage::helper('monkey')->__('Send to MailChimp'),
'url' => Mage::getModel('adminhtml/url')->getUrl('adminhtml/ecommerce/masssend', Mage::app()->getStore()->isCurrentlySecure() ? array('_secure' => true) : array()),
));
}
}
return $observer;
}
The only block inside of the second extension has a class and extend as such:
class EM_DeleteOrder_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
there is no dispatch event in that block file? Could that be the issue?
Can anyone see an issue in the observer logic so the if's might not evaluate to true because the class's are different? I thought because they must extend the mage core classes then instanceof would still work?
Does any of this look like something that would be hindered by an extension extending core classes or overriding them?
Edit:
the config.xml of the second extension is:
<?xml version="1.0"?>
<config>
<modules>
<EM_DeleteOrder>
<version>1.0.0</version>
</EM_DeleteOrder>
</modules>
<global>
<rewrite>
<em_emadmin_adminhtml_sales_order>
<from><![CDATA[#/admin/sales_order/#]]></from>
<to>/emadmin/adminhtml_sales_order/</to>
</em_emadmin_adminhtml_sales_order>
</rewrite>
<blocks>
<adminhtml>
<rewrite>
<sales_order_grid>EM_DeleteOrder_Block_Adminhtml_Sales_Order_Grid</sales_order_grid>
</rewrite>
</adminhtml>
</blocks>
</global>
<admin>
<routers>
<em_deleteorder>
<use>admin</use>
<args>
<module>EM_DeleteOrder</module>
<frontName>emadmin</frontName>
</args>
</em_deleteorder>
<adminhtml>
<args>
<modules>
<EM_DeleteOrder_Adminhtml before="Mage_Adminhtml">EM_DeleteOrder_Adminhtml</EM_DeleteOrder_Adminhtml>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
Will some of these rewrites cause the issues? I notice that it rewrites sales_order_grid and it seems to rewrite admin/sales_order and those are included in if's in the observer?
Mage::log("test");
before the condition andMage::log("test 2");
inside the condition. Then check yourvar/log/system.log
file. Also try addingMage::log(__FUNCTION__);
at the beginning of your function to ensure the method is trigerred