Note that there are some explanatory texts on larger screens.

plurals
  1. POOrder view page print pdf button magento
    primarykey
    data
    text
    <p>I am trying to add a print order button on the main order detail page on the magento admin. The client's old magento had a print button for the order itself (paid or unpaid, not invoice). See what it used to look like:</p> <p><img src="https://i.stack.imgur.com/ZjiJL.jpg" alt="orderbar"></p> <p>I've enabled template hints in on the back end and the template file does not contain that button. I've been through several core files... The html looks like the following. How would I turn that into a php button that is applicable to the currently viewed order?</p> <pre><code>&lt;button id="id_d808fbd2d533d4e7b8e4a3fcd6274251" title="Back" type="button" class="scalable back" onclick="setLocation('http://test.animalnecessity.com/index.php/admin/sales_order/index/order_id/15852/key/28a65aa166da1664c65971decf3e472c/')" style=""&gt; </code></pre> <p>Could I implement this? <a href="https://stackoverflow.com/questions/10691895/magento-add-button-to-sales-order-view-page-observer-event">Magento - Add Button to Sales Order View Page (Observer/Event)</a> and if so where would I put this code? <br><br> I have it set up with the typical module structure as described here: <a href="http://alanstorm.com/magento_config" rel="nofollow noreferrer">http://alanstorm.com/magento_config</a>. My config.xml in the etc folder has the following</p> <pre><code>&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>My CaitlinHavener_printOrder.xml the following</p> <pre><code>&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>and Observer.php</p> <pre><code>&lt;?php // Order View Page button class CaitlinHavener_printOrder_Model_Observer { public function orderPageButton( Varien_Event_Observer $observer ) { 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>This is still not working. Any ideas?</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. COYou are missing $block variable initialization: $block = $observer->getEvent()->getData( 'block' ); // this should be the first line of orderPageButton function. It should work after that :)
      singulars
    2. COBtw you should change a few things in index.php. 1) Mage::setIsDeveloperMode(true); <- comment if that surrounds this line 2) ini_set('display_errors', 1); <- uncomment this line; These two cnages will enable logs in var/log/{system, exception}.log; it's easyer to develop that way and there won't be so many bugs in production - it's surprising how many people develop magento stores without that and then when I start working on a project and enable those logs I'm greeted with allot of errors in logs that should be fixed before production
      singulars
    3. COOne more thing... printOrder <- Module name should start with an upper case CaitlinHavener_PrintOrder_... It's usualy that way and you can get into some serious trouble with upper case to underscore and back automatic magento conversions on for e.g. Linux OS because of case sensitive file system. In my example I intentionaly wrote correct upper/lower cased words. I don't know if that's a problem in your case since I copied your code to my module and renamed things but just an advice in case you run into such trouble :)
      singulars
 

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