Saturday 20 July 2013

Call Direct Template page from controller in magento.

Call Direct Template page from controller.

if ($this->getRequest()->getParam('result') > 0) {
$this->loadLayout();
            if((bool) $this->getRequest()->getParam('result')){
                $this->_initLayoutMessages('customer/session');
                $this->_initLayoutMessages('catalog/session');
                 if ($block = $this->getLayout()->getBlock('root')) {
                    $block->setRefererUrl($this->_getRefererUrl());
                }
                $this->getLayout()->getBlock('root')->setTemplate('quiz/result_rating.phtml'); //changes the root which if you want template.
            }
            $this->renderLayout();
            return $this;
}

Friday 19 July 2013

Get product price in Magento

<?php
// assuming that you have known product object, $_product
//get product price snippet
echo $this->getPriceHtml($_product, true);
//get $_product price
echo $_product->getPrice();
echo number_format($_product->getPrice(), '2', '.', ',');
//get $_product special price
echo $_product->getSpecialPrice();
echo number_format($_product->getSpecialPrice(), '2', '.', ',');
//get $_product final price
echo $_prodcut->getFinalPrice();
echo number_format($_product->getFinalPrice(), '2', '.', ',');
//get $_product Msrp
echo $_product->getMsrp();
echo number_format($_product->getMsrp(), '2', '.', ',');
?>