I am written the code for Recent Viewed Products on footer.phtml, but it's not showing.
my code is:
local.xml
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<default>
<reference name="root">
<action method="setTemplate">
<template>page/2columns-left.phtml</template>
<action method="setIsHandle">
<applied>1</applied>
</action>
</action>
</reference>
<!-- 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"
template="reports/product_viewed.phtml"/>
</reference>
</default>
footer.phtml
<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') ?>
</div>
shopper/default/template/reports/product_viewed.phtml
<?php
ob_start();
/* @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>
<div class="block-content">
<ul>
<?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()) ?>" />
</a>
<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) ?>
</div>
</li>
<?php endforeach; ?>
</ul>
<script type="text/javascript">decorateList('recently-viewed-items');</script>
</div>
</div>
<?php endif; ?>
<?php
$queldorei_blocks = Mage::registry('queldorei_blocks');
if ( !$queldorei_blocks ) {
$queldorei_blocks = array();
} else {
Mage::unregister('queldorei_blocks');
}
$queldorei_blocks['block_viewed'] = ob_get_clean();
Mage::register('queldorei_blocks', $queldorei_blocks);
can you tell me where i went wrong?
Thanks in advance.
Best Answer
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 codeand call it in
footer.phtml
usingThe 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 frombase
folder.NOTE: Always try the default Magento code if you face any errors in the theme to check the origin of error