I am written the code for Recent Viewed Products on footer.phtml, but it's not showing.

my code is:


<?xml version="1.0" encoding="UTF-8"?>


        <reference name="root">
            <action method="setTemplate">
                <action method="setIsHandle">

        <!-- Remove callouts and rarely used stuff -->
        <remove name="right.poll"/>
        <remove name="right.permanent.callout"/>
        <remove name="left.permanent.callout"/>
        <remove name="paypal.partner.right.logo"/>
        <remove name="cart_sidebar"/>
 <reference name="footer">
            <block type="reports/product_viewed" name="product.recently.viewed" as="product_recently_viewed"



<div class="block-content">
                <!--?php echo $this->getLayout()->createBlock('reports/product_viewed')->setTemplate('reports/‌​product_viewed.phtml')->toHtml(); ?-->
                <?php echo $this->getChildHtml('product_recently_viewed') ?>



/* @var $this Mage_Reports_Block_Product_Viewed */

$helper = $this->helper('shoppersettings/image');
$imgX = 56;
$imgY = $helper->calculateHeight($imgX);
$_helper = $this->helper('catalog/output');
<?php if ($_products = $this->getRecentlyViewedProducts()): ?>
<div class="block block-list block-viewed">
    <div class="block-title">
        <strong><span><?php echo $this->__('Recently Viewed Products') ?></span></strong>
    <div class="block-content">
            <?php foreach ( $_products as $_product ) : ?>
            <li class="clearfix">
                <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" class="product-image">
                    <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($imgX, $imgY) ?>" data-srcX2="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($imgX*2, $imgY*2) ?>" width="<?php echo $imgX; ?>" height="<?php echo $imgY; ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" />
                <div class="product-info">
                    <?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
                    <a class="product-name" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a>
                    <?php echo $this->getPriceHtml($_product, true) ?>
            <?php endforeach; ?>
        <script type="text/javascript">decorateList('recently-viewed-items');</script>
<?php endif; ?>
$queldorei_blocks = Mage::registry('queldorei_blocks');
if ( !$queldorei_blocks ) {
$queldorei_blocks = array();
} else {
$queldorei_blocks['block_viewed'] = ob_get_clean();
Mage::register('queldorei_blocks', $queldorei_blocks);

can you tell me where i went wrong?

Thanks in advance.

  • Did you add the block in page.xml??
    – dh47
    Nov 26, 2014 at 9:37
  • @dh47, Yes in local.xml i have added. Nov 26, 2014 at 9:41
  • The code looks fine and works perfectly. Are you sure you have used <?php echo $this->getLayout()->createBlock('reports/product_viewed')->setTemplate('reports/product_viewed.phtml')->toHtml(); ?> code. Have you tried clearing the caches?
    – Dexter
    Nov 26, 2014 at 10:02
  • @Dexter, did you tried footer.phtml file or ? Nov 26, 2014 at 10:12
  • @Dexter, sorry, it's returning error message Not valid template file:frontend\base\default\template\reports/‌​product_viewed.phtml. Nov 26, 2014 at 10:15

1 Answer 1


To call recently viewed product in your footer you can try as below:

in your app/design/frontend/{yourTheme}/default/layout/local.xml file add code

<reference name="footer"> 
   <block type="reports/product_viewed" name="product.recently.viewed" as="product_recently_viewed" template="reports/product_viewed.phtml"/> 

and call it in footer.phtml using

<?php echo $this->getChildHtml('product_recently_viewed') ?>

The problem you are facing is because of the third party theme you have used. Clean up the code from reports/product_viewed.phtml and replace it with default file from base folder.

NOTE: Always try the default Magento code if you face any errors in the theme to check the origin of error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.