Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9178941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:40:24+00:00 2026-06-17T17:40:24+00:00

I am trying to add a print order button on the main order detail

  • 0

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:

orderbar

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?

<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="">

Could I implement this? Magento – Add Button to Sales Order View Page (Observer/Event) and if so where would I put this code?

I have it set up with the typical module structure as described here: http://alanstorm.com/magento_config. My config.xml in the etc folder has the following

<config>    
    <modules>
        <CaitlinHavener_printOrder>
            <version>0.1.0</version>
        </CaitlinHavener_printOrder>
    </modules>
    <global>
        <events>
            <core_block_abstract_to_html_before>
                <observers>
                <CaitlinHavener_printOrder>
                    <class>CaitlinHavener_printOrder_Model_Observer</class>
                    <method>orderPageButton</method>
                    <type>model</type>
                </CaitlinHavener_printOrder>
                </observers>
            </core_block_abstract_to_html_before>
        </events>
    </global>
</config>

My CaitlinHavener_printOrder.xml the following

<config>    
    <modules>
        <CaitlinHavener_printOrder>
            <active>true</active>
            <codePool>local</codePool>
        </CaitlinHavener_printOrder>
    </modules>
</config>

and Observer.php

<?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'
            && $block->getRequest()->getControllerName() == 'sales_order')
        {
            $block->addButton('test_print', array(
                'label'     => 'Test',
                'onclick'   => 'setLocation(\'' . $block->getUrl('html/sales_order/print') . '\')',
                'class'     => 'go'
            ));
        }
    }
}
?>

This is still not working. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:40:26+00:00Added an answer on June 17, 2026 at 5:40 pm

    The buttons are created in Mage_Adminhtml_Block_Sales_Order_View::__construct with $this->addButton function calls.

    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.

    To list all the events that get triggered you could add logging into Mage::dispatchEvent function with Mage::log( $name );

    With that name you could declare a listener in config.xml (under config/global/events tag path):

      <name_that_was_printed_by_the_above_function>
        <observers>
          <YourModuleNamespace_YourModuleName>
            <class>moduleName/observer</class>
            <method>functionName</method>
            <type>model</type>
          </YourModuleNamespace_YourModuleName>
        </observers>
      </name_that_was_printed_by_the_above_function>
    

    and then create a module class Observer.php

    class Namespace_ModuleName_Model_Observer
    {
        public function functionName( Varien_Event_Observer $observer )
        {
            $block = $observer->getEvent()->getData( 'data_object' ); // this line may vary
    
            $block->addButton( ...stuff here... // take for reference the answer from the question you linked to
            return $this;
        }
    }
    

    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…

    Edit

    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).

    Edit

    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.

    app/etc/modules/CaitlinHavener_PrintOrder.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <config>    
        <modules>
            <CaitlinHavener_PrintOrder>
                <active>true</active>
                <codePool>local</codePool>
            </CaitlinHavener_PrintOrder>
        </modules>
    </config>
    

    app/code/local/CaitlinHavener/PrintOrder/etc/config.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <config>    
        <modules>
            <CaitlinHavener_PrintOrder>
                <version>0.1.0</version>
            </CaitlinHavener_PrintOrder>
        </modules>
        <global>
            <events>
                <core_block_abstract_to_html_before>
                    <observers>
                    <CaitlinHavener_PrintOrder>
                        <class>CaitlinHavener_PrintOrder_Model_Observer</class>
                        <method>orderPageButton</method>
                        <type>model</type>
                    </CaitlinHavener_PrintOrder>
                    </observers>
                </core_block_abstract_to_html_before>
            </events>
        </global>
    </config>
    

    local/CaitlinHavener/PrintOrder/Model/Observer.php

    <?php
    // Order View Page button    
    class CaitlinHavener_PrintOrder_Model_Observer
    {
        public function orderPageButton( Varien_Event_Observer $observer )
        {
          $block = $observer->getEvent()->getData( 'block' );
    
            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'
                ));
            }
        }
    }
    ?>
    

    Be carefull that you correctly name your files (watch for upper case characters) and copy the code and it should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to modify the HTML markup of a page in order to add
I'm trying to add a custom printing button (like print invoice) on the Sales
I'm trying to add Internet access to my application and in order to do
I'm trying to customize the html print order (url http://www.yoursite.com/index.php/sales/order/print/order_id/8/ ) but I can't
I'm trying add data triggers to the default combobox style so each text item
I am trying add picture boxes dynamically. My code is as PictureBox picture =
Im new to asp.net mvc. I'm trying add new model class but it got
Trying to add init parameter names to a list in init(ServletConfig) method. public void
Trying to add a blank sample app for a rails tutorial to GitHub, but
Trying to add a 'box' to a form at design time, I looked up

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.