0

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);

3

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

  • Thanks for the link, Meenakshi. Just so confirm my understanding, is Magento using dynamically named methods for setting and getting session variables? Looking at Mage/Core/Model/Session/Abstract/Varien.php, the start() method calls call_user_func_array('session_set_cookie_params', $cookieParams); – Vee Aug 9 '15 at 17:12
0

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');
    }

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.