a1anm
a1anm

Reputation: 1629

Magento - Display Individual Products

Is there an easy way in Magento to display individual products in a cms page without copying and pasting the code from the catalog pages?

I have a blog on my magento store and sometimes I'd like to drop the listing for individual products into the posts.

Upvotes: 2

Views: 5954

Answers (2)

liquidity
liquidity

Reputation: 1323

If you are working on Magento 1.4, you should take a look at widgets which do exactly what you want.

Upvotes: 0

Shaun
Shaun

Reputation: 4799

A code block in Magento is the best way to achieve this effect. If you look at your home page, that's how new products are generated dynamically:

{{block type="catalog/product_new" template="catalog/product/new.phtml"}}

If you created another block for a 'featured' item that took a product ID as a parameter, you could place that block on the static page and it would show that item. This page shows a brief example, but for the sake of being complete, I'll reproduce it here:

First create a new .phtml file with the following undercatalog/product/view/your_new_page.phtml

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

Now simply add the following to your CMS Page or Block and adjust the product ID to the product Image you wish to view:

{{block type="catalog/product_new" product_id="1" template="catalog/product/view/your_new_page.phtml"}}

I'd probably tweak it a bit for readability if I used this on my store, but I'm also a bit overzealous in terms of using human-readable code. :)

Upvotes: 2

Related Questions