1

I was looking for some help to create an extra button in the area in the screen shot below. Basically, I have created a Custom Transactional Email which I would like to use to send to customers if their order is going to be delayed slightly.

In other words, if the product they ordered is on backorder, I just want a way to send a quick email stating their order is going to be delayed since the product is in production.

Most of our products can be manufactured in a day if need be. We end up building to order at certain times of the year, since the order volume trumps our capabilities.

We can not really use the Back Order feature of Magento 1.8.1 simply because we sell products on other sites rather than just our own. So we have to keep a running total of inventory for everything instead of just Magento.

Any help with this topic will be greatly appreciated. I have not had to do much to our website in the past year so a little rusty.

Thanks,

Ryan

enter image description here

1 Answer 1

0

Off the cuff here goes.

  1. Create a new extension. If you all ready have a custom extension that you are maintaining you may be able to add to this.
  2. In your config.xml for you extension add the following to the adminhtml node. This tells magento to listen for the core_block_abstract_prepare_layout_after event and call the addButtonToOrderView method in your Your_Custommodule_Model_Observer when this event is dispatched.

        <events>
            <core_block_abstract_prepare_layout_after>
                <observers>
                    <some_name_that_makes_sense_add_button_observer>
                        <type>singleton</type>
                        <class>Your_Custommodule_Model_Observer</class>
                        <method>addButtonToOrderView</method>
                    </some_name_that_makes_sense_add_button_observer>
                </observers>
            </core_block_abstract_prepare_layout_after>
        <events>
    
  3. Create class Your_Custommodule_Model_Observer. This will be responsible for adding the button.

  4. Add the following method to your observer.

    public function addButtonToOrderView(Varien_Event_Observer $observer){
        // only add to order view block
        if($observer->getEvent()->getBlock() instanceof Mage_Adminhtml_Block_Sales_Order_View){
            $saleOrderViewBlock = $observer->getEvent()->getBlock();
            // url of the controller for handling the sending of the email
            $url = $saleOrderViewBlock->getUrl('routeto/yourcontroller/sendemail',
                array('order_id' => $saleOrderViewBlock->getOrder()->getId()));
    
            // we now add the button
            $saleOrderViewBlock->addButton('send_custom_email', array(
                'label'     => Mage::helper('sales')->__('Send Custom Email'),
                'onclick'   => "setLocation('$url')",
            ));
        }
    }
    
  5. Implement your controller

3
  • Thank you very much for this information. I am having a little trouble calling the controller. I am trying to incorporate this into an Extension which is actually used to send the email if the order has not been shipped within 7 days. But I would like to have this button so we could send the email earlier if need be. Or be able to send another email after the automated email was sent at day 7.
    – RLTcode
    Commented Jun 28, 2016 at 17:11
  • Does the existing extension have a controller? If so whats it's class name and module route for the adminhtml? Commented Jun 28, 2016 at 23:31
  • No controller, just 3 files in Model directory, 1 Data file in Helper directory and 3 files (config, system, adminhtml) in etc directory. 1 of the files in the Model directory is where it gets all the information for the email though. The other 2 are basically just checking for a valid license. Also the file in app/etc/modules, but that is all the files. It sounds like a need to create a controller file then?
    – RLTcode
    Commented Jun 29, 2016 at 21:23

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.