PHP Magento Tips

Get Add to Cart URL of a Product in Magento

Rate this posting:
{[['']]}

When you know your product ID, sku number or store id then load the product Object from any one of the below methods and get your "Add to Cart" url by passing this product object to the checkout/cart helper.

$product=Mage::getModel('catalog/product')->load($productId);//load the product by product id
$product=Mage::getModel('catalog/product')->loadByAttribute('sku',$skuNum);//or load the product by sku number
$product=Mage::getModel('catalog/product')->setStoreId($storeId)->loadByAttribute('sku',$skuNum);//or load the product from a given store id

echo Mage::helper('checkout/cart')->getAddUrl($product);//Get the add to cart url



Tag : Magento
1 Comments On "Get Add to Cart URL of a Product in Magento"

I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Typo3, kindly contact us http://www.maxmunus.com/contact
MaxMunus Offer World Class Virtual Instructor led training on Typo3. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
For Demo Contact us:
Name : Arunkumar U
Email : arun@maxmunus.com
Skype id: training_maxmunus
Contact No.-+91-9738507310
Company Website –http://www.maxmunus.com


Back To Top