Get Add to Cart URL of any Product in Magento



In this tutorial I will show you how to get Add to Cart URL of any Product in Magento. It will help when you will create a custom page for any product.

Following is the code to get add to cart url of any product. For example we need to fetch add to cart url of a product id “123”.

$_productId = '123';
$_product = Mage::getModel('catalog/product')->load($_productId);
$_url = Mage::helper('checkout/cart')->getAddUrl($_product);

Now you can use this $_url with button or link to use as add to cart. Hope this tutorial will help you to get add to cart url of any product.