Jump to content

[SOLVED] Pre-populate Viewed Products


Mallee Boy

Recommended Posts

I allow three products in my viewed products module.

I want to pre-populate my viewed products module so that new visitors will see something down the right column where the module later appears. I still want their own products to eventually fill the module as they browse.



Is pre-populating the module possible?

Link to comment
Share on other sites

You could try changing line 71 of modules/blockviewed/blockviewed.php from:

$productsViewed = (isset($params['cookie']->viewed) AND !empty($params['cookie']->viewed)) ? array_slice(explode(',', $params['cookie']->viewed), 0, Configuration::get('PRODUCTS_VIEWED_NBR')) : array();



to:

$productsViewed = (isset($params['cookie']->viewed) AND !empty($params['cookie']->viewed)) ? array_slice(explode(',', $params['cookie']->viewed), 0, Configuration::get('PRODUCTS_VIEWED_NBR')) : array();

if (sizeof($productsViewed) == 0)
  $productsViewed = '1,2,3';



This should display products 1, 2 and 3 when no viewed products exist in the cookie. Once a product is viewed, it should replace the default products.

I'm not sure whether this is a good idea though. It may be confusing for a customer to see "Viewed products" that they haven't viewed.

Link to comment
Share on other sites

Rocky, tried your suggestion, but nothing. Are the "1,2,3" a reference to product ID's? I tried some other product ID's (111,16,11) but still nothng.

here are lines 71-75 with your edits:

        $productsViewed = (isset($params['cookie']->viewed) AND !empty($params['cookie']->viewed)) ? array_slice(explode(',', $params['cookie']->viewed), 0, Configuration::get('PRODUCTS_VIEWED_NBR')) : array();

if (sizeof($productsViewed) == 0)
  $productsViewed = '1,2,3';
           if (sizeof($productsViewed))



Would really like to solve this if it is possible.

Regarding the idea itself, I hear what you are saying - there is a sane reason behind the change.

Link to comment
Share on other sites

You are right. I didn't notice that I added the line after the explode, not before. Try:

$productsViewed = (isset($params['cookie']->viewed) AND !empty($params['cookie']->viewed)) ? array_slice(explode(',', $params['cookie']->viewed), 0, Configuration::get('PRODUCTS_VIEWED_NBR')) : array();

if (sizeof($productsViewed) == 0)
  $productsViewed = array(1, 2, 3);

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...