Question

In my magento application created a phtml page in template/page/ folder..

Here displayed a products...Then there is a need for displaying

$this->getAddToCartUrl($product)

But it return null value...that means no value returned it.

How can i get it in my phtml page?

This is the html code:

<input id="url_<?php echo $_iterator;?>" name="url_$_iterator;" type="text" value="<?php echo $this->getAddToCartUrl($product) ?>">
Was it helpful?

Solution

Try calling this instead:

$this->helper('checkout/cart')->getAddUrl($product)

OTHER TIPS

Using the helper 'checkout/cart' with get link but it want solve the problem as you will run with similar issues with the price.

I think it is better to change if you can change the template type definition in your xml, something like this:

<block type="catalog/product_list" template="your-template.phtml" name="your-name" as="your-name" />

Like that you will have in $this not only the link but the price with out calling the magento helper directly.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top