How can I fetch Order URL on frontend just like its done in Customer Account dashboard > My Orders ?

The code written in history.phtml file for Order URL is as under:

<span class="nobr"><a href="<?php echo $this->getViewUrl($_order) ?>"><?php echo $this->__('View Order') ?></a>

How can I call the function getVIewUrl() and pass my order_id to fetch the Order URL ?

I do not want to use BaseUrl() and then append sales/order/view/order/id/$orderId.

Please Help


1 Answer 1


Use this:

Mage::getUrl('sales/order/view', array('order_id'=>$orderId));  
  • Are there any chances of me using getViewUrl() function here ?
    – Jordan
    Aug 20, 2014 at 10:26
  • Don't use getViewUrl unless you are in the same block. That method works only in that specific block. If you try to instantiate the block in an other page and use getViewUrl you might end up with strange results. I think what I suggested is the safest way to go.
    – Marius
    Aug 20, 2014 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.