0

I see extensions and solutions for adding next previous navigation to the product page frontend but that isn't what we need.

We need the following:

  1. On Magento CE 1.7.0.2 - Admin panel->Sales->Orders

  2. Open order so you are viewing it

  3. Have a next and previous button/link on the top with other buttons to manage order. Clicking next will bring you to next consecutive order.

Best Regards,

George

kc2keo
  • 92
  • 2
  • 14

1 Answers1

0

Try create a custom module that rewrite Mage_Adminhtml_Block_Sales_Order_View

config.xml:

<global>
    <blocks>
         <adminhtml>
            <rewrite>
                <sales_order_view>MageIgniter_NextBackButton_Block_Adminhtml_Sales_Order_View</sales_order_view>
            </rewrite>
        </adminhtml>
    </blocks>
 </global>

MageIgniter/NextPreviousButton/Block/Adminhtml/Sales/Order/View.php:

class MageIgniter_NextBackButton_Block_Adminhtml_Sales_Order_View extends Mage_Adminhtml_Block_Sales_Order_View {

  public function  __construct() {
     if($url = $this->getPreviousUrl()){
       $this->_addButton('previous_button', array(
           'label'     => Mage::helper('sales')->__('Previous'),
           'onclick'   => 'setLocation(\'' . $url . '\')',
           'class'     => 'go'
       ));
     }

     if($url = $this->getNextUrl()){
       $this->_addButton('next_button', array(
           'label'     => Mage::helper('sales')->__('Next'),
           'onclick'   => 'setLocation(\'' . $url . '\')',
           'class'     => 'go'
       ));
     }

     parent::__construct();
  }

  // to convert to magento orm
  //http://www.magentocommerce.com/answers/discussion/3752/Filter-Order-Collection-by-attribute1-OR-attribute2/p1
  public function  getNextUrl() {
       $current_order_id = $this->getOrder()->getId();
       // get $id from db
       SELECT * FROM foo WHERE id > $current_order_id ORDER BY id LIMIT 1;
       // if found return 
       $this->getUrl('*/sales_order/view', array('order_id'=>$id))
      //else return false - at last record
  }

  public function  getPreviousUrl() {
       $current_order_id = $this->getOrder()->getId();
       // get $id from db
       SELECT * FROM foo WHERE id < $current_order_id ORDER BY id LIMIT 1;

       // if found return 
       $this->getUrl('*/sales_order/view', array('order_id'=>$id))
      //else return false - at last record
  }

}

See /app/code/core/Mage/Adminhtml/Block/Sales/Order/View.php

Read more @ How to add new button to order view in Magento admin panel?

Community
  • 1
  • 1
MagePal Extensions
  • 17,646
  • 2
  • 47
  • 62