0

Okay, I am a very new magento developer. Here is what I am facing.

  • Module one -> is adding a button to sales order page by rewriting sales_order_view
  • Module two -> is adding a button to sales order page by Observer (the new approach)

This ends up only showing Module one buttons.

How can this be fixed in a way where buttons from both modules show up ?

Module1-Buttons are being added via this pastebin.com/U8ujJpV5

Module2-Buttons are being added via this pastebin.com/j6VxwfF5 .

If I should post something more than this please let me know but I believe this would explain the problem.

Thank you

3
  • 2
    Some code may help us understand better
    – Marius
    Sep 2, 2014 at 14:17
  • Module1-Buttons are being added via this pastebin.com/U8ujJpV5 Module2-Buttons are being added via this pastebin.com/j6VxwfF5 . If I should post something more than this please let me know but I believe this would explain the problem. Thank you
    – sami1255
    Sep 2, 2014 at 18:14
  • @sami1255 please check my edited answer below.
    – Simon
    Sep 11, 2014 at 18:30

1 Answer 1

2

In general, the buttons of both modules should show up. Ideas why this is not the case:

  • Module one which rewrites the block removes the dispatchEvent call of the event used by the second module. I think this is rather unlikely, because most of the time a quite generic event is used in order to add the button.
  • The modules add the buttons with the same sortOrder. If this is the case, Magento will only show one of the buttons. I published a fix for for that bug on GitHub.

Alright, now that you posted the code I could comprehend it. The reason why it does not work is that the code which uses the observer method checks the block class like that:

get_class($block) == 'Mage_Adminhtml_Block_Sales_Order_View'

And only if that condition is true it will add the button. Since the other module rewrites the block and the block type is then Aramex_Shipment_Block_Sales_Order_View, this check will fail every time. What you can do:

  1. Change the check to $block instanceof Mage_Adminhtml_Block_Sales_Order_View - this is the better way and it works with that check. If this is not your extension, consider writing the author and propose this change.
  2. [not recommended] Change the check to get_class($block) == 'Aramex_Shipment_Block_Sales_Order_View'.
  3. Change the Aramex_Shipment extension to also add the button via the event/observer method. If this is not your extension, consider writing the author and propose this change.

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.