3

I feel like I am missing something. Using the CMS. I am trying to link a img to a product page using variables.

Basically

<a href="{{product}}"><img src="{{media image}}" /></a>

Is there a button on the TinyMCE that I can use to create this?

2 Answers 2

1

Try this way

<a href="{{store direct_url="product-url.html"}}"><img src="{{media url='/imagename.jpg'}}" /></a>
2
  • I understand this method, but is there any way I can do this without manually getting the product link? Commented Sep 17, 2015 at 16:21
  • do you mean you want to set product URL dynamically in cms block? If yes, unfortunately you can't do that this way which you are trying to do. For that you will need to use block and template file and you can call it in CMS page and use dynamic product URL and media image in that template file. Commented Sep 17, 2015 at 16:30
0

You could write a phtml.

 <a href="<?php echo $_product->getProductUrl()  ?>">
    <img src="<?php echo (string)Mage::helper('catalog/image')->init($_product, 'thumbnail')->resize(100); ?>" alt="" />
 </a>

Then bring it in cms page or static block. Like this

{{block type="core/template" template="your/custom/file.phtml"}}

Path will be after your theme template folder.

Resize(100) will resize your image in 100x100 square. Change it based on your needs.

Remember to fully load the product.

EDIT: I am writing from a mobile phone and stackexchange breaks my html. I hope you get the idea.

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.