[Magento] Random price templates

Data dodania wpisu: 17-09-2010

Sometimes there is a need to display the same product price by several templates on the same page. How to create random price template to display it several times, each one themed in another way? Commonly, there is one price template for products:


To continue our purpose, we have to create new method in:


by this way:

public function getPriceHtmlRandomTemplate($product, $template) 
        return $this->_getPriceBlock($product->getTypeId()) 

This method does load price template from path given in $template variable.

Next we need to do, is ti call this method for example on a Simple Product page:


The code calling new method could be:

<?php echo $this->getPriceHtmlRandomTemplate($_product, 'catalog/product/random_price_template.phtml') ?>

New file (random_price_template.phtml) is just a copy of price.phtml, however could be modified in another way, ie. for additional CSS styles.


This entry has no comments yet

Comments closed...

DesignEnd on Facebook