Joomla 3.5.1
JoomShopping 4.14.1
Plugin & Module: Last visited products

In general, there is a module:

 defined ('_JEXEC') or die;

 if (! file_exists (JPATH_SITE. '/ components / com_jshopping / jshopping.php')) {
     JError :: raiseError (500, "Please install component \" joomshopping \ "");
 } 

 require_once JPATH_SITE. '/ components / com_jshopping / lib / factory.php'; 
 require_once JPATH_SITE. '/ components / com_jshopping / lib / functions.php';        
 JSFactory :: loadCssFiles ();
 JSFactory :: loadLanguageFile ();
 $ jshopConfig = JSFactory :: getConfig ();
 $ session = JFactory :: getSession ();

 $ count = $ params-> get ('count_products', 5);
 $ show_image = $ params-> get ('show_image', 1);
 $ show_name = $ params-> get ('show_name', 1);
 $ show_price = $ params-> get ('show_price', 1);
 $ show_manufacturer = $ params-> get ('show_manufacturer', 1);
 $ show_module = $ params-> get ('show_module', 1);

 $ products = array ();
 $ last_visited_products = array_reverse ($ session-> get ('last_visited_products', array ()));
 $ curent_product_id = JFactory :: getApplication () -> input-> getInt ('product_id');
 foreach ($ last_visited_products as $ product) {
     if ($ product-> product_id == $ curent_product_id) {
         continue;
     }
     $ product-> product_price = $ product-> orig_product_price;
     $ product-> image = $ product-> orig_image;
     if (count ($ products) noimage)) {
     $ noimage = $ jshopConfig-> noimage;
 } else {
     $ noimage = 'noimage.gif';
 }

 require JModuleHelper :: getLayoutPath ($ module-> module, $ params-> get ('layout', 'default'));



And the plugin:

 defined ('_ JEXEC') or die;

 class plgJshoppingproductsJshopping_last_visit_product extends JPlugin {

     function onBeforeDisplayProductView ($ view) {
         $ session = JFactory :: getSession ();
         $ last_visited_products = $ session-> get ('last_visited_products', array ());
         if (isset ($ last_visited_products [$ view-> product-> product_id])) {
             unset ($ last_visited_products [$ view-> product-> product_id]);
         }
         $ product = new stdClass ();
         $ product-> name = $ view-> product-> name;
         $ product-> orig_image = $ view-> product-> image;
         $ product-> image = $ view-> product-> image;
         $ product-> product_thumb_image = $ view-> product-> product_thumb_image;
         $ product-> product_id = $ view-> product-> product_id;
         $ product-> currency_id = $ view-> product-> currency_id;
         $ product-> tax_id = $ view-> product-> product_tax_id;
         $ product-> orig_product_price = $ view-> product-> product_price;
         $ product-> product_price = $ view-> product-> product_price;
         $ product-> product_old_price = $ view-> product-> product_old_price;
         $ product-> min_price = $ view-> product-> min_price;
         $ product-> different_prices = $ view-> product-> different_prices;
         $ product-> product_manufacturer_id = $ view-> product-> product_manufacturer_id;
         $ product-> vendor_id = $ view-> product-> vendor_id;
         $ product-> delivery_times_id = $ view-> product-> delivery_times_id;
         $ product-> label_id = $ view-> product-> label_id;
         $ product-> category_id = $ view-> category_id;
         $ last_visited_products [$ product-> product_id] = $ product;
         $ session-> set ('last_visited_products', $ last_visited_products);
     }

 }



Both of them store information about the last viewed products in SESSION . Need to change the way information is stored on COOKIE .
There are suggestions how to implement it ??

  • I think it will not work. Cook size is limited, and you store in the session an array of products with visits to each time. The more products a user visits, the larger the array. And at some point an overflow error will occur. - Visman
  • @Visman need to store several products and not all, for example, 3-5. To store in cookies (in my inexperienced opinion) you need only product_id, and then determine all other variables by it. Plus there are similar paid solutions, then everything is possible !!! - Danil
  • No more assumptions? Or the question is somehow incorrectly posed. Any reaction would be ... - Danil

0