a1anm
a1anm

Reputation: 1629

Magento - Display Same Block Multiple Times on CMS Page

I'm using the method described here to display an individual product on a cms page:

http://www.molotovbliss.com/magento-commerce/magento-display-a-product-image-within-static-pages-and-blocks/

The problem is that if I try to display 2 products using this method both blocks show the same product even if I specify a different id in each block ie:

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

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

Adding the above code to my cms page results in product 1 being displayed twice.

Upvotes: 0

Views: 3267

Answers (3)

borux
borux

Reputation: 46

Here is the solution change product_new to product_view like this: type="catalog/product_view" have fun :)

Upvotes: 3

Lee Saferite
Lee Saferite

Reputation: 3124

Without knowing exactly what version of Magento you are running, I chose to look at 1.3.2.4 for you.

Oddly, I'm suprised you get any good result using 'catalog/product_new'. It has no provision for passing in the product id as a block arg. 'catalog/product_view' will allow you to pass in the product id as an arg, but only once. If you notice below, it's sets the product as a registry object the first time and will not use the passed in product id after that.

public function getProduct()
{
    if (!Mage::registry('product') && $this->getProductId()) {
        $product = Mage::getModel('catalog/product')->load($this->getProductId());
        Mage::register('product', $product);
    }
    return Mage::registry('product');
}

Upvotes: 2

Hervé Guétin
Hervé Guétin

Reputation: 4392

My 2 cents (not beeing sure though...) : did you try to set a name to each block ? Like :

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

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

Upvotes: 0

Related Questions