cancel
Showing results for 
Search instead for 
Did you mean: 

How to alter Magento Packing Slips Printing sort order ?

How to alter Magento Packing Slips Printing sort order ?

hi all,

 

First it is good to see the magento forum is back Smiley Happy

My client has a special requirement that is , he has a large warehouse and it is sorded by brands. So end of the day they will print Packing Slips and search for products in the warehouse , since warehouse is sorted by brand order they will need to print Packing Slips by the brand

 

what I'm going to do is we have already installed AITOC brands module and first I will add a additional field to "Manage attribute page" of AITOC brand module to define sort order for each brand and then when print packing slips they should print by above pre defined brand order , any idea of how to do it ?

_______________________________________________
An Expert in Anything Was Once a Beginner
6 REPLIES

Re: How to alter Magento Packing Slips Printing sort order ?

Hi Chamal

 

I'm not sure about AITOC's brand module, but if it works with Magento's standard Attributes (as it should Smiley Wink), you can add some simple Joins to make your collection order by the attribute sorting.

 

$shippingItemCollection->getSelect()
->joinLeft(
	array('attribute_values' => 'catalog_product_entity_int'), 
	'main_table.product_id = attribute_values.entity_id AND attribute_values.attribute_id = *INSERT ATTRIBUTE ID TO SORT BY HERE* AND attribute_values.store_id = 0', 
	array())
->joinLeft(
	array('attribute_options' => 'eav_attribute_option'), 
	'attribute_options.option_id = attribute_values.value', 
	array())
->order('attribute_options.sort_order ASC');

 

If it doesn't use Magento's Attributes, the code will be very different. 

 

To add these joins's to the collection you need to find the colleciton that prints your PDF and make a rewrite to that object, or rewrite the action totaly and make a seperat model for handling this specific case since rewriting the model might cause these changes to apply in multiple places.

 

Hope this helps :-)

Re: How to alter Magento Packing Slips Printing sort order ?

thank you very much for replying to my question , I have to use brands product attribute to sort the collection for a given order guess as you said it is possible but Tesis do you know where is the magento default packing slip printing module located ? 

_______________________________________________
An Expert in Anything Was Once a Beginner

Re: How to alter Magento Packing Slips Printing sort order ?

Hi Chamal

 

Yes the default functionallity depends on the shipping object (Mage_Sales_Model_Order_Shipment), and the method: getAllItems which in turns uses the getItemsCollection method. 

 

getItemsCollection is the method actually fetching the data, but since the collection object loads within the method, you can't modify the select object. So you need to do a complete rewrite of the method like this:

 

    public function getItemsCollection()
    {
        if (empty($this->_items)) {
            $this->_items = Mage::getResourceModel('sales/order_shipment_item_collection')
                ->setShipmentFilter($this->getId());

            $this->_items->getSelect()
            ->joinLeft(
                array('attribute_values' => 'catalog_product_entity_int'), 
                'main_table.product_id = attribute_values.entity_id AND attribute_values.attribute_id = *INSERT ATTRIBUTE ID TO SORT BY HERE* AND attribute_values.store_id = 0', 
                array())
            ->joinLeft(
                array('attribute_options' => 'eav_attribute_option'), 
                'attribute_options.option_id = attribute_values.value', 
                array())
            ->order('attribute_options.sort_order ASC');

            if ($this->getId()) {
                foreach ($this->_items as $item) {
                    $item->setShipment($this);
                }
            }
        }
        return $this->_items;
    }

 

Do note that this method is used by other parts of the system so rewriting it will affect multiple locations. Remember to replace my text: *INSERT ATTRIBUTE ID TO SORT BY HERE* with the attributes actually attributes numeric ID.

 

Re: How to alter Magento Packing Slips Printing sort order ?

Hello Chamal,

 

We'd like to confirm that our extension "Shop by Brands" does work with Magento Attributes (it uses manufacturer by default). So, it looks like the solution proposed by Theis Corfixen should work. 

 

Please, let us know if we can help with anything else!

 


Aitoc is a group of distinguished web developers that have been building for Magento since 2009.
See our extensions for Magento 2.

Re: How do we find the magento packing slip, we don't seem to have one on version 1.3

Hello

 

Can anybody help? We are wanting a packing slip and we don't appear to have one, where do we get this from?

 

Re: How do we find the magento packing slip, we don't seem to have one on version 1.3

@champandgifts: Do you want to print it before or after your shipment is created ?


French Magento Solution Specialist.
Looking for Magento consultancy ? Contact me !