Search code examples
url-rewritingmagento-1.5magento

Magento Admin Sales > Order > Item Url


I am trying to create a link from my helpdesk software to the sales order page in the backend of magento.

Magento constructs the url as the example below where the number represents the Order ID.

/index.php/admin/sales_order/view/order_id/12394/

However, the Order Id does not equal the Order Number because credit invoices etc. are included in the count.

Is there an other way for me to link to the order page using the Order Number.

Thanks!


Solution

  • There are 2 types of order number in magento

    1. Order increment id
    2. Order id (mostly use internal in magento).

    The admin uses the order id while the number on you invoice is the order increment id.

    The quickest way to get around this is to create a custom module that look up order id by order increment id and the redirect to the view page using the order id.

    In /app/etc/modules/MageIgniter_OrderRedirect.xml

    <?xml version="1.0"?>
    <config>
      <modules>
        <MageIgniter_OrderRedirect>
          <active>true</active>
          <codePool>local</codePool>
        </MageIgniter_OrderRedirect>
      </modules>
    </config>
    

    In /app/code/local/MageIgniter/OrderRedirect/controllers/RedirectOrderController.php

    <?php
    
    class MageIgniter_OrderRedirect_RedirectOrderController extends Mage_Core_Controller_Front_Action
    {
        public function viewAction(){
    
           $increment_id = Mage::app()->getRequest()->getParam('id');
           $order = Mage::getModel('sales/order')->loadByIncrementId($increment_id);
           $order_id = $order->getId();
    
           Mage::app()->getResponse()->setRedirect(Mage::helper('adminhtml')->getUrl("adminhtml/sales_order/view", array('order_id'=> $order_id)));
        }
     }
    

    in In /app/code/local/MageIgniter/OrderRedirect/etc/config.xml

    <?xml version="1.0"?>
    <config>
      <modules>
        <MageIgniter_OrderRedirect>
          <version>0.1.0</version>
        </MageIgniter_OrderRedirect>
      </modules>
      <frontend>
        <routers>
            <orderredirect>
                <use>standard</use>
                <args>
                    <module>MageIgniter_OrderRedirect</module>
                    <frontName>orderredirect</frontName>
                </args>
            </orderredirect>
        </routers>
     </frontend>   
      <global>
        <helpers>
          <orderredirect>
            <class>MageIgniter_OrderRedirect_Helper</class>
          </orderredirect>
        </helpers>
      </global>
    </config> 
    

    url

    www.site.com/orderredirect/redirectOrder/view/id/101512486