cancel
Showing results for 
Search instead for 
Did you mean: 

order pdf (picking list), sort by location code

order pdf (picking list), sort by location code

I have made an order pdf, a picking list, which shows the barcodes and locations of each product. It is based on another pdf extension.
Now I want to sort the pdf by location_shelf. Some products have the same location shelf.

This is the piece of codes so far which works fine, if each product has an unique location.
It is found in /app/code/local/Custom/Extension/Model/Order/Pdf/Order.php and it extends Mage_Sales_Model_Order_Pdf_Abstract
The function is    

    public function getPdf($orders = array())
/* Add body */
           $items = $order->getAllItems()  ; // Gets items --- need to sort them first! 
            $_sortedItems = array();        
                // build array, inserts order items into array and sort

            foreach ($items as $item) :
                $_sortedItems[$item->getProduct()->getData("location_shelf")] = $item;
            endforeach;

            ksort($_sortedItems);
            foreach ($_sortedItems as $item) {   //pass sorted items back one at a time in alpha' order

            if ($item->getParentItem()) {
                continue;

                }
                
                if ($this->y < 200) {
                    $page = $this->newPage(array());
                }

                $position++;
                /* Draw item */

It is based on another piece of code I found which sorts the products by name. How do I get to display all the products, even when the location_shelf is the same?