is this possible? I'm using one controller for (almost) the same functionality for two different pages. Is it possible to distinguish the source of the request in order to vary functionality?

Note: This controller is used to process ajax calls.

2 Answers 2


You can get the current url with Mage::helper('core/url')->getCurrentUrl().

As @mbalparda said, the request object could be better for your purposes.

Try these methods:

$request = $this->getRequest();


With this you can get your route, controller and action without parsing an URL.

  • Mage::helper('core/url')->getCurrentUrl() returns the URL of the controller that is used to process these requests. Feb 5, 2015 at 15:18
  • 1
    Sorry, didn't quite understand your question the first time. Looking at this question I think that Mage::app()->getRequest()->getServer('HTTP_REFERER') could be useful.
    – Isaias
    Feb 5, 2015 at 15:23
  • Is this method can return url with query string or note for ex "www.xyz.com/products?p=1" like this? Nov 16, 2018 at 9:02

Use $this->getRequest() to see how can you differentiate the requests. Inside that var you will have some more details about the request. Dump it and see what is inside and act consequently with the info.

  • The requests set to this controller from the two different pages (cart and checkout) are indistinguishable. Feb 5, 2015 at 15:20
  • 2
    Dump the var and you will see more things than the request path, for example the referrer.
    – mbalparda
    Feb 5, 2015 at 15:21

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.