Question

I'm using Magento 1.9 and am trying to gain a better understanding of the method, getContinueShoppingUrl(), when called by Mage::getSingleton('checkout/session') but can't seem to find the file that defines the method. Tracing through class inheritance, this is what I've got:

core/Mage/Checkout/Model/Session.php:

class Mage_Checkout_Model_Session extends Mage_Core_Model_Session_Abstract
{
    /* getContinueShoppingUrl() not defined */
}

core/Mage/Core/Model/Session/Abstract.php:

class Mage_Core_Model_Session_Abstract extends Mage_Core_Model_Session_Abstract_Varien
{
    /* getContinueShoppingUrl() not defined */
}

core/Mage/Core/Model/Session/Abstract/Varien.php:

class Mage_Core_Model_Session_Abstract_Varien extends Varien_Object
{
    /* getContinueShoppingUrl() not defined */
}

lib/Varien/Object.php:

class Varien_Object implements ArrayAccess
{
    /* getContinueShoppingUrl() not defined */
}

So how does getContinueShoppingUrl get called by Mage::getSingleton('checkout/session')? The only place that I found a definition for the method was in core/Mage/Checkout/Block/Cart.php but the getContinueShoppingUrl() method in class Mage_Checkout_Block_Cart is where I started the trace for: Mage::getSingleton('checkout/session')->getContinueShoppingUrl(true);

Was it helpful?

Solution

continue_shopping_url is a session variable. You can set the session value for this variable.

The session value is set here Mage_Checkout_Block_Cart::getContinueShoppingUrl()

public function getContinueShoppingUrl()
{
   $url = $this->getData('continue_shopping_url');
    if (is_null($url)) {
      $url = Mage::getSingleton('checkout/session')->getContinueShoppingUrl(true);
      if (!$url) {
        $url = Mage::getUrl();
       }
       $this->setData('continue_shopping_url', $url);
   }
   return $url;
}

To get better understanding for the set and get session value refer this link

OTHER TIPS

getContinueShoppingUrl is defined in two places:

app/code/core/Mage/Checkout/Block/Cart.php

public function getContinueShoppingUrl()
{
    $url = $this->getData('continue_shopping_url');
    if (is_null($url)) {
        $url = Mage::getSingleton('checkout/session')->getContinueShoppingUrl(true);
        if (!$url) {
            $url = Mage::getUrl();
        }
        $this->setData('continue_shopping_url', $url);
    }
    return $url;
}

app/code/core/Mage/Checkout/Block/Onepage/Failure.php

public function getContinueShoppingUrl()
    {
        return Mage::getUrl('checkout/cart');
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top