Suneth Kalhara
Suneth Kalhara

Reputation: 1208

Magento Recently Viewed Products for non logged users

I'm using default magento 1.9.x Recently Viewed Products block on a CMS page

{{block type="reports/product_viewed" template="reports/product_viewed.phtml"}}

But default magento Recently Viewed Products block only support for logged in users, so it only show when i logged in

I checked the file

/public_html/app/code/core/Mage/Reports/Block/Product/Abstract.php

and It's line number 138 function set a customer id for product collection for filter the results.

But i think normal site visitors not have that kind of id.

if ($this->getCustomerId()) { 
                       $this->_collection->setCustomerId($this->getCustomerId());
 }

Anyone know how to get recently viewed products by setting an id to above or by using another way.

i also tried this answer but it didn't work at all

How to get Recently View Product For Guest User In Magento

Upvotes: 0

Views: 912

Answers (1)

Abhinav Kumar Singh
Abhinav Kumar Singh

Reputation: 2325

Step 1 : Go to Admin ->CMS->Pages->AnyCmsPage

Step 2 : Go to-> AnyCmsPage-> Design

Step 3 :Copy and Pase the following code in Layout Update XML

<reference name="content">
<block type="reports/product_viewed" name="home.reports.product.viewed" alias="product_viewed" template="reports/home_product_viewed.phtml" after="product_new">
    <action method="addPriceBlockType">
        <type>bundle</type>
        <block>bundle/catalog_product_price</block>
        <template>bundle/catalog/product/price.phtml</template>
    </action>
</block>
</reference>

Upvotes: 1

Related Questions