I have found two function returning the exactly same value.
getAddUrl
in \app\code\local\Mage\Checkout\Helper\Cart.php
getAddToCartUrl
in \app\code\local\Mage\Catalog\Block\Product\Abstract.php
what is really the difference between these two, as I am adding an add to cart button in my block.
Which function should I use to add the product to the cart ?
Best Answer
The code under
Mage_Catalog_Block_Product_Abstract
has a very useful comment.The difference is that the
Mage_Catalog_Block_Product_Abstract::getAddToCartUrl
will set the url as the product view page if the product has required options, otherwise it will just returnMage_Checkout_Helper_Cart::getAddUrl
.The
getAddToCartUrl
can be used when you are not on the product view page, say for the wishlist page. So that you do not get an error when the user tries to add a product to the cart that has required options.