So, I've got a CMS page that I'm using as a landing page. I want to add a button that lets customers add a product straight to the shopping cart, completely bypassing the main product page. The usual php methods for making an add-to-cart product link don't work from a CMS page. Is there some way to call these via the CMS interface with the replacement syntax {{foo}}? If not, how do I get the link I need?

Relevant info:

We are using the obfuscated add-to-cart format, so the normal query url doesn't seem to work.

Our product links and ids don't seem to be stable, so I can't just copy-paste something.

Yes, this landing page needs to be a CMS page, not hardcoded in the site.

2 Answers 2


I would just use the {{block}} directive to call your own .phtml file. You could do something such as:

{{block type="core/template" template="your_template.phtml" product="52"}}

Remember, any additional directive you set will get assigned to that block, so in this case, product="52" will basically do setProduct('52') on the block, allowing you to getProduct(). Alternatively, you could set a SKU or any other type of ID you would like to use.

Now, inside your template file, simply use:

<?php $product = Mage::getModel('catalog/product')->load($this->getProduct()) ?>
<?php echo Mage::helper('checkout/cart')->getAddUrl($product) ?>

It's important to use the helper method, as it will add the form key to the URL for you.

As another alternative, you could set up a widget to do this; though, personally I prefer using the {{block}} directive.

  • 2
    This is actually a nice approach. +1
    – Marius
    Jun 30, 2014 at 14:22
  • How can i solve the add to cart button error, justpaste.it/6fi1f
    – Gem
    Aug 9, 2018 at 6:14

From Magento version 1.8 on wards, I think, you need to specify a form_key in the url when adding a product to the cart.

In another answer from Marius on the subject he suggested writing your own method to add products to the cart without the form_key. This is a good idea.

To raise another idea what you could is create a widget that adds an add to cart button to a cms page. Here you could use the same product chooser as in the product link widget. Then in the front end of your widget you can use the following function to get the add to cart url.


Where $_product is the product attached via the widget.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.