Forums / All Other Contributions/Addons / Is there a plugin to show how many times a product has been viewed?

Is there a plugin to show how many times a product has been viewed?

Started by zadris on 2 Jun 2012, 8:54 PM · Views: 997

Results 1 to 3 of 3
2 Jun 2012, 8:54 PM
#1
zadris avatar

zadris

New Zenner

Join Date:
Oct 2011
Posts:
68
Plugin Contributions:
0

Is there a plugin to show how many times a product has been viewed?

Hello!

I was wondering if there is a such a plugin for product viewed on the products page? Where it shows how many times that product has been viewed.

I have looked through the plugins...tried different words and nothing came up..just curious if I missed it.

Thanks!

3 Jun 2012, 12:33 AM
#2
balihr avatar

balihr

Totally Zenned

Join Date:
Oct 2008
Location:
Croatia
Posts:
1,809
Plugin Contributions:
22

Re: Is there a plugin to show how many times a product has been viewed?

I don't think there's a plugin available just for that, but you can easily accomplish it with a few minor edits.

First, edit you includes/modules/pages/product_info/main_template_vars.php and replace this $sql = "select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id, p.products_quantity, p.products_weight, p.products_priced_by_attribute, p.product_is_free, p.products_qty_box_status, p.products_quantity_order_max, p.products_discount_type, p.products_discount_type_from, p.products_sort_order, p.products_price_sorter from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$_GET['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'"; with ```
$sql = "select p.products_id, pd.products_name,
pd.products_description, p.products_model,
p.products_quantity, p.products_image,
pd.products_url, p.products_price,
p.products_tax_class_id, p.products_date_added,
p.products_date_available, p.manufacturers_id, p.products_quantity,
p.products_weight, p.products_priced_by_attribute, p.product_is_free,
p.products_qty_box_status,
p.products_quantity_order_max,
p.products_discount_type, p.products_discount_type_from, p.products_sort_order, p.products_price_sorter, pd.products_viewed
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_status = '1'
and p.products_id = '" . (int)$_GET['products_id'] . "'
and pd.products_id = p.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";

Then, add ```
$products_viewed = $product_info->fields['products_viewed'];
``` somewhere between lines 99 and 133, for example right after ```
$products_url = $product_info->fields['products_url'];

Next, edit your includes/templates/YOUR_TEMPLATE/templates/tpl_product_info_display.php and add the following line where you want to display the counter: ```

<?php echo 'This product was viewed ' . $products_viewed . ' times'; ?>

The language is obviously hard-coded in this case, but you can easily change it into a definition if you want...

My site - Pro ZC Help
My portfolio | My plugins

4 Jun 2012, 8:57 PM
#3
zadris avatar

zadris

New Zenner

Join Date:
Oct 2011
Posts:
68
Plugin Contributions:
0

Re: Is there a plugin to show how many times a product has been viewed?

thanks! i am going to give it a try..