Tutorials for Magento and Joomla! - Yireo

Video: Dynamic product image to Static Page

This tutorial explains how to create a dynamic product image to a Magento CMS Page. Within the CMS Page you still need to define which product-ID to use, but when the product image changes the CMS Page automatically shows the updated image.

Note: This information originally comes from molotov.bliss (www.molotovbliss.com). We've only used that information to create a video tutorial from it. Kudos to Jared.

Below is the code used in the video tutorial. It should be placed in your copy of app/design/frontend/default/default/template/catalog/product/view/your_new_page.phtml. Do not modify the original, but only make your changes within your own theming-directory.

 
<?php
$productId = $this->getProduct_id(); 
$_product = Mage::getModel('catalog/product')->load($productId);
?>
<img src="<? echo Mage::helper('catalog/image')->init($_product, 'thumbnail')->resize(75, 75); ?>" alt="<?php echo $this->htmlEscape($_product['name']); ?>" border="0" width="75" />
 

Also, add the following to your own CMS Page or CMS Block. Adjust the product ID ("product_id") to point to the proper product whose image you wish to display:

{{block type="catalog/product_new" product_id="1" template="catalog/product/view/your_new_page.phtml"}}
Created on Monday, 09 November 2009
Modified on Sunday, 06 December 2009

About Yireo

Yireo tries to help webdevelopers build successful Joomla! and Magento sites.

More about Yireo