5

ゲスト ユーザーに最近の製品を表示したいときに 1 つの問題に直面しています。最近表示した製品をゲスト ユーザーに表示する方法はありますか?

Magento のサポート 登録ユーザー向けの最近の製品を表示 ゲスト ユーザー向け 表示方法 その特定のゲストによる最近の製品を表示...

親切な対応をお待ちしております、

これについて何らかの返事が返ってくることを願っています。

前もって感謝します。

4

3 に答える 3

2

最近閲覧した製品のブロックは、magento 1.6-1.9.2.2 でコードを変更しなくても正常に動作し
ます。ブロックが表示されない場合は、以下を確認する必要があります。

  1. ブロックは、表示されているコンテナーのページに適切に追加されます (デフォルトでは、右側のサイドバーにブロックが追加されます)
  2. ログは有効です。[システム] -> [構成] -> [システム] -> [ログ] オプションの [ログを有効にする] = [はい] を確認します
  3. インデックス「カテゴリ製品」を再構築 (catalog_category_product)
于 2015-12-12T19:36:57.200 に答える
2

ここに.htmlがあります

<?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ファイル

class Mage_Reports_Block_Product_Viewed extends Mage_Reports_Block_Product_Abstract
{
const XML_PATH_RECENTLY_VIEWED_COUNT    = 'catalog/recently_products/viewed_count';

/**
 * Viewed Product Index model name
 *
 * @var string
 */
protected $_indexName       = 'reports/product_index_viewed';

/**
 * Retrieve page size (count)
 *
 * @return int
 */
public function getPageSize()
{
    if ($this->hasData('page_size')) {
        return $this->getData('page_size');
    }
    return Mage::getStoreConfig(self::XML_PATH_RECENTLY_VIEWED_COUNT);
}

/**
 * Added predefined ids support
 */
public function getCount()
{
    $ids = $this->getProductIds();
    if (!empty($ids)) {
        return count($ids);
    }
    return parent::getCount();
}

/**
 * Prepare to html
 * check has viewed products
 *
 * @return string
 */
protected function _toHtml()
{
    if (!$this->getCount()) {
        return '';
    }
    $this->setRecentlyViewedProducts($this->getItemsCollection());
    return parent::_toHtml();
}
}

ゲストで機能しない場合は、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();
}
于 2013-03-29T07:32:07.527 に答える
0

私の知る限り、ゲストには問題なく機能するはずです。少なくとも私のサイトでは機能します。これをページに配置する方法は次のとおりです。

<block type="reports/product_viewed" name="reports.product.recently.viewed" template="reports/recently_viewed.phtml" />
于 2013-03-28T13:39:01.617 に答える