在使用magento的时候,Recently Viewed Product,这个功能是有的,但是对于一些隐藏分类,是通过一些别的途径点进去的,为了更好的增加客户体验,需要Recently Viewed Category这个功能,也就是客户的分类访问历史记录,下面就是实现这个magento Recently Viewed Category</a>功能的代码,放在分类页面访问时候的页面,譬如放在标签<catalog_category_layered >和<catalog_category_default>里面的left中,在访问分类页面的时候能访问就行,原理就是将客户访问的历史记录加入到session中,然后在提取出来,这样客户就可以查看到自己访问分类的历史记录了!
<?php
$sess = Mage::getSingleton("core/session", array("name" => "frontend"));
//$data = $this->getRequest()->getPost();
//$dd = $_GET['user'];
$cate = $_SESSION['Codess'];
$_helper = $this->helper('catalog/output');
$_category = $this->getCurrentCategory();
$catename = $_helper->categoryAttribute($_category, $this->htmlEscape($_category->getName()), 'name');
$url = $_category->getUrl();
$ta = array();
$now = array($catename=>$url);
//var_dump($now);
?>
<?php if($cate!=""){ ?>
<div class="block block-list block-viewed">
<div class="block-title">
<strong><span><?php echo 'Recently Viewed Category'; ?></span></strong>
</div>
<div class="block-content">
<ol id="recently-viewed-items">
<?php foreach ($cate as $fir=>$end) {?>
<li class="item">
<?php echo "<a href='".$end."'> ".$fir." </a>"; ?>
</li>
<?php } ?>
</ol>
</div>
</div>
<?php } ?>
<?php
if($cate==""){
$_SESSION['Codess'] = $now;
}else{
$aray = $_SESSION['Codess'];
$aray[$catename] = $url;
//var_dump($aray);
$_SESSION['Codess'] = $aray;
}
?>
转载请务必标注地址:magento定制:http://www.magentowater.com/blog/Recently-Viewed-Category