如何在Magento中为来宾用户获取最近查看的产品
当我想为来宾用户显示最近的产品时,我面临一个问题,是否有任何方法可以为来宾用户显示最近查看的产品 Magento支持注册用户最近查看产品,但对于来宾用户,则支持如何显示该特定来宾最近查看的产品 我在等待你的善意回应 希望我能得到一些回复如何在Magento中为来宾用户获取最近查看的产品,magento,Magento,当我想为来宾用户显示最近的产品时,我面临一个问题,是否有任何方法可以为来宾用户显示最近查看的产品 Magento支持注册用户最近查看产品,但对于来宾用户,则支持如何显示该特定来宾最近查看的产品 我在等待你的善意回应 希望我能得到一些回复 提前谢谢。据我所知,这对客人来说应该很好用。至少它在我的网站上有效 下面是我如何将其放在页面上的: <block type="reports/product_viewed" name="reports.product.recently.viewed" te
提前谢谢。据我所知,这对客人来说应该很好用。至少它在我的网站上有效 下面是我如何将其放在页面上的:
<block type="reports/product_viewed" name="reports.product.recently.viewed" template="reports/recently_viewed.phtml" />
这是phtml
<?php if ($_products = $this->getRecentlyViewedProducts()):
$ids = '';
foreach ($_products as $_item) {
$ids .= $_item->getId() . ';';
}
?>
<div class="lftHeading">
<span
style="text-transform:capitalize;background:url(<?php echo $this->getSkinUrl('css/images/clo_left_heading_bullet2.gif') ?>) top left no-repeat;"
>recently viewed</span>
</div>
<div class="innerRgtMenu recently_viewed_block">
<table id="recently-viewed-items">
<?php $i = 0; foreach ($_products as $_item): if ($i == 3) {
continue;
} ?>
<?php $product = $_item ?>
<tr>
<td><a style="border:1px solid #DDDDDD;float:left;margin:5px;padding:5px;"
href="<?php echo $this->getProductUrl($_item, array('_nosid' => true)) ?>" class="product-image"><img
src="<?php echo $this->helper('catalog/image')->init($product, 'thumbnail')->resize(50) ?>"
width="50" alt="<?php echo $this->escapeHtml($_item->getName()) ?>"/></a></td>
<td><a style="position:relative;top:3px;font-size:11px;"
href="<?php echo $this->getProductUrl($_item, array('_nosid' => true)) ?>"><?php echo $this->escapeHtml($_item->getName()) ?></a>
</td>
</tr>
<?php $i++;
endforeach; ?>
</table>
<div style="margin: 5px 0px 5px 2px; text-align: center; width: 140px;">
<input type="button" class="button recently_viewed_btn" value="<?php echo $this->__('Email These To Me') ?> "
onClick="email_recently('<?php echo $ids; ?>')"/>
</div>
<div style="margin:5px;">
<a href="<?php echo $this->getBaseUrl() ?>recently-viewed-items/"><?php echo $this->__('See All Recently Viewed') ?></a>
</div>
<script type="text/javascript">decorateList('recently-viewed-items');</script>
如果它不适用于来宾-尝试将php文件中的最后一个函数更改为
protected function _toHtml()
{
/* if ($this->_hasViewedProductsBefore() === false) {
return '';
} */
$this->setDisplayMinimalPrice('1');
$collection = $this->_getRecentProductsCollection();
$hasProducts = (bool)count($collection);
// if (is_null($this->_hasViewedProductsBefore())) {
// Mage::getSingleton('reports/session')->setData('viewed_products', $hasProducts);
// }
if ($hasProducts) {
$this->setRecentlyViewedProducts($collection);
}
return parent::_toHtml();
}
阻止最近查看的产品在magento 1.6-1.9.2.2中无需任何代码修改即可正常工作
如果未显示块,则需要检查:
我想你可以改变核心文件…你试过吗?是的。我也需要这个功能。哦,谢谢你的友好回复,我做到了,但magento不支持来宾用户最近查看产品你好,我的朋友,我想magento 1702中没有最近查看的.phtml文件。请将你最近查看的.phtml文件复制/粘贴到这里,以便我了解你在网站中的设置。谢谢你的帮助亲切的回应这是帮助我,但它不会显示最近查看产品一旦我关闭我的浏览器,并再次回来有任何选择!这些产品保存在会话中,所以可能只是会话过期了是的,我做了,它的工作,但我想向来宾用户显示与注册用户相同的最近查看产品!您是否注意到,当注册用户关闭浏览器并返回时,它将显示他上次访问的最近的产品!所以,我希望客人用户也一样,一旦他们关闭浏览器,再次回到我的网站,他将得到他最近查看的产品。我想你从一开始就有了想法。但是在这个网站上,默认情况下这对客人有效。因此,您的问题可能基于会话生存期。我看不到任何其他原因,对不起。这没关系,我的朋友,但你的解决方案对我有效。我在cookies中为来宾用户设置了最近查看产品,这样它将向他们显示最近查看产品。谢谢你的友好回复
protected function _toHtml()
{
/* if ($this->_hasViewedProductsBefore() === false) {
return '';
} */
$this->setDisplayMinimalPrice('1');
$collection = $this->_getRecentProductsCollection();
$hasProducts = (bool)count($collection);
// if (is_null($this->_hasViewedProductsBefore())) {
// Mage::getSingleton('reports/session')->setData('viewed_products', $hasProducts);
// }
if ($hasProducts) {
$this->setRecentlyViewedProducts($collection);
}
return parent::_toHtml();
}