1

I need to add a feature to my website that creates picking list for warehouse.

When you go to sales>orders>view an order>shipments>click on a shipment> You will see a print button which prints picking slip. I want to add a button called e-mail. When you click on the button it should send the picking list to an e-mail I set. Also I need to change the picking slip template.

For also learning purpose could you help me please? So where should I start? Where can I change the template and how can I add the e-mail button?

Thanks.

1

1 Answer 1

1

If you want to build this yourself you would have to start out with building your own extension. There are a couple of nice tutorials on that here and here but it comes down to having an extension with a config.xml, perhaps a Data helper and Models.

The config.xml would look something like this:

<?xml version="1.0"?>
<config>
    <modules>
        <[Namespace]_[Module]>
            <version>1.0.0</version>
        </[Namespace]_[Module]>
    </modules>
    <global>
        <models>
            <[module]>
                <class>[Namespace]_[Module]_Model</class>
            </[module]>
        </models>
        <helpers>
            <[module]>
                <class>[Namespace]_[Module]_Helper</class>
            </[module]>
        </helpers>
    </global>
</config>

Now moving on to actually kicking into action when a shipment is created. For this Magento offers Events. A nice tutorial on events can be found here. We just need to find the right event that triggers when the Shipment is created. We can use the Magento 1.7 event cheatsheet for that. sales_order_shipment_save_after should do the trick for you. Lets start by adding your observer to the config.xml INSIDE the global tag.

<events>
    <sales_order_shipment_save_after>
        <observers>
            <[module]_shipping_observer>
                <type>singleton</type>
                <class>[Namespace]_[Module]_Model_Observer</class>
                <method>sendList</method>
            </[module]_shipping_observer>
        </observers>
    </sales_order_shipment_save_after>     
</events>

This tells Magento to fire class [Namespace]_[Module]_Model_Observer, method sendList when the event is triggered.

Now we can add the final piece, the Observer Model. Create a file in the Model directory called Observer.php and insert the following code.

<?php 

class [Namespace]_[Module]_Model_Observer extends Mage_Core_Model_Abstract 
{

    public function sendList($observer)
    {
        $shipment = $observer->getEvent()->getShipment();
        $order = $shipment->getOrder();

        [...] 
        retrieve items and send email
        [...]
    }

}

Now you have your basic observer. You will need to add code to retrieve the items of a shipment, probably something along the lines of $products = Mage::getResourceModel('sales/order_item_collection')->setOrderFilter($orderid); and I suggest using this tutorial or this tutoral on how to send the email.

1
  • No problem, let me know how it went :) Commented Aug 27, 2013 at 9:54

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.