I would like to get the URL of the product which was recently added to cart (lastly added to the cart) and assign it to Continue Shopping url in cart page.


In Magento, there have a checkout session variable which is store lastly added to the cart item products id.


and using this product id with help product model,you can get url easily.

$product_collection = Mage::getModel('catalog/product')->getCollection()
    ->addAttributeToFilter('entity_id', Mage::getSingleton('checkout/session')>getLastAddedProductId())
$product_collection_url = $product_collection->getFirstItem()->getProductUrl()

Here i have product/collection model getting data firster

| improve this answer | |
  • But this gets the last added product ID only once.. I want it to be maintained throughout.. – Swetha Oct 10 '15 at 4:27

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.