Magento - Add Button to Sales Order View Page (Observer/Event)

后端 未结 2 1735
孤城傲影
孤城傲影 2021-01-07 07:00

I\'m trying to add a custom printing button (like print invoice) on the Sales Order View page (Sales > Orders > Order #... view).

I\'ve do

相关标签:
2条回答
  • 2021-01-07 07:12

    I solved it a little bit after I posted. The solution for me was the following:

    // Order View Page button
            if(get_class($block) =='Mage_Adminhtml_Block_Sales_Order_View'
                && $block->getRequest()->getControllerName() == 'sales_order')
            {
                $block->addButton('test_print', array(
                    'label'     => 'Test',
                    'onclick'   => 'setLocation(\'' . $block->getUrl('html/sales_order/print') . '\')',
                    'class'     => 'go'
                ));
            }
    
    0 讨论(0)
  • 2021-01-07 07:32

    In Magento, any class function starting with an underscore is defined as private or protected -- it's the naming convention the core team uses -- so you cannot call it from outside the class. This is why $block->_addButton() does not work.

    The good news is you can call $block->addButton() (no underscore). This is the public method that Mage_Adminhtml_Block_Widget_Container provides you.

    Also, you can't call addButton() from $this, because $this is pointing to your observer class, which doesn't have an addButton() method defined (which is what your error is saying).

    0 讨论(0)
提交回复
热议问题