Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The buttons are created in Mage_Adminhtml_Block_Sales_Order_View::__construct with $this->addButton function calls.</p> <p>As for the events you could use one of them but I can't recall from the top of my head which one (if any) would be apropriate to call.</p> <p>To list all the events that get triggered you could add logging into Mage::dispatchEvent function with Mage::log( $name );</p> <p>With that name you could declare a listener in config.xml (under config/global/events tag path):</p> <pre><code> &lt;name_that_was_printed_by_the_above_function&gt; &lt;observers&gt; &lt;YourModuleNamespace_YourModuleName&gt; &lt;class&gt;moduleName/observer&lt;/class&gt; &lt;method&gt;functionName&lt;/method&gt; &lt;type&gt;model&lt;/type&gt; &lt;/YourModuleNamespace_YourModuleName&gt; &lt;/observers&gt; &lt;/name_that_was_printed_by_the_above_function&gt; </code></pre> <p>and then create a module class Observer.php</p> <pre><code>class Namespace_ModuleName_Model_Observer { public function functionName( Varien_Event_Observer $observer ) { $block = $observer-&gt;getEvent()-&gt;getData( 'data_object' ); // this line may vary $block-&gt;addButton( ...stuff here... // take for reference the answer from the question you linked to return $this; } } </code></pre> <p>But like I said it's possible that none of the observers will suit your needs and you'll have to find another more intrusive solution...</p> <p><strong>Edit</strong></p> <p>You'll probbably have to use core_block_abstract_to_html_before and have an if statement to check if it's the right block... The downside is that it gives a call overhead and an if statement overhead for every block so I'm not certain if it's the best solution but it's certainly the least intrusive so I'd probably use it (the 'data_object' should be changed to 'block' in case of this event - event is triggered in Mage_Core_Block_Abstract::toHtml the dispatchEvent line).</p> <p><strong>Edit</strong></p> <p>After your question update I've tested your module and like I have warned in the comments the problem is the name of your module - lower case.</p> <p>app/etc/modules/CaitlinHavener_PrintOrder.xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;config&gt; &lt;modules&gt; &lt;CaitlinHavener_PrintOrder&gt; &lt;active&gt;true&lt;/active&gt; &lt;codePool&gt;local&lt;/codePool&gt; &lt;/CaitlinHavener_PrintOrder&gt; &lt;/modules&gt; &lt;/config&gt; </code></pre> <p>app/code/local/CaitlinHavener/PrintOrder/etc/config.xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;config&gt; &lt;modules&gt; &lt;CaitlinHavener_PrintOrder&gt; &lt;version&gt;0.1.0&lt;/version&gt; &lt;/CaitlinHavener_PrintOrder&gt; &lt;/modules&gt; &lt;global&gt; &lt;events&gt; &lt;core_block_abstract_to_html_before&gt; &lt;observers&gt; &lt;CaitlinHavener_PrintOrder&gt; &lt;class&gt;CaitlinHavener_PrintOrder_Model_Observer&lt;/class&gt; &lt;method&gt;orderPageButton&lt;/method&gt; &lt;type&gt;model&lt;/type&gt; &lt;/CaitlinHavener_PrintOrder&gt; &lt;/observers&gt; &lt;/core_block_abstract_to_html_before&gt; &lt;/events&gt; &lt;/global&gt; &lt;/config&gt; </code></pre> <p>local/CaitlinHavener/PrintOrder/Model/Observer.php</p> <pre><code>&lt;?php // Order View Page button class CaitlinHavener_PrintOrder_Model_Observer { public function orderPageButton( Varien_Event_Observer $observer ) { $block = $observer-&gt;getEvent()-&gt;getData( 'block' ); if(get_class($block) =='Mage_Adminhtml_Block_Sales_Order_View' &amp;&amp; $block-&gt;getRequest()-&gt;getControllerName() == 'sales_order') { $block-&gt;addButton('test_print', array( 'label' =&gt; 'Test', 'onclick' =&gt; 'setLocation(\'' . $block-&gt;getUrl('html/sales_order/print') . '\')', 'class' =&gt; 'go' )); } } } ?&gt; </code></pre> <p>Be carefull that you correctly name your files (watch for upper case characters) and copy the code and it should work.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload