Jump to content

[FREE TUTORIAL] Product page views counter for prestashop 1.6 / 1.5


Recommended Posts

new working feature for prestashop 1.5.x and 1.6.x


free tutorial


 


I've noticed several times that many merchants asking about this feature for prestashop 1.5.x / 1.6.x


so here it is :) totally free and easy in use modification


 


enjoy!


 


product page views counter


product-page-views-count-prestashop.jpg


Share this post


Link to post
Share on other sites
  • 1 month later...

Hello :)

 

Your help is most appreciated.

I used this suggestion, but it does not work on all products!?

This is my page: http://delvine.dk

And on this page it do not seem to work: EX.: This page: http://delvine.dk/mendoza/24-2011-luca-chardonnay-laura-catena.html

 

product.tpl:  <!-- end box-info-product -->
            </form>
            {/if}<table width="260" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td style="text-align: center;"><a class="product_page_koncept" href="http://delvine.dk/content/4-om-os" target="_self">Læs koncept før bestilling!</a></td>
  </tr>
  <tr>
    <td height="187" class="page_views_txt" style="text-align: center; vertical-align: top;"><br />
      UNIKKE BESØG:<br />
      Denne side er set<br />
<span class="page_view_number">{FrontController::getTotalViewed(Tools::getValue('id_product'))}</span> gange<br />
                                                    siden Maj 2014
</td>
  </tr>
</table>
        </div>
       
        <!-- end pb-right-column-->

 

I am still running in demo-mode. 

 

yours friendly Bhodi

 

ps: today it does not seem to work on any page

Edited by Bhodi (see edit history)

Share this post


Link to post
Share on other sites

Ahh,

 

perhaps I will only be counted one time, and never again?!

 

Actually i don't think they work - they don't count even after two days

Datamining is activated.

 

Strange though - in the beginning some pages would count on refresh browser, and others only changed to '1' and never again! Now noone is changing.

 

yours friendly - Bhodi

Edited by Bhodi (see edit history)

Share this post


Link to post
Share on other sites
  • 3 months later...

AWESOME. A question regarding this one, is it possible to add a counter on the frontpage for each product as well.  To best explain what i mean is to look at this site, it has a heart and a eye to show how many make it a favorite and how many have seen it: http://dwellinggawker.com/post/tag/hack/page/2/

 

I would love to see this kind of feature on the following location:

- The frontpage, on each thumbnail for each product

- The quick-view page

- the main product page

 

Can someone tell me which files i must edit and where in the file i past the code?

 

Frank

Share this post


Link to post
Share on other sites
  • 4 weeks later...

use this code:

 

 public static function getTotalViewed($id_product){ 
                 $view1 = Db::getInstance()->getRow('SELECT SUM(pv.counter) AS total FROM '._DB_PREFIX_.'page_viewed pv 
                  LEFT JOIN '._DB_PREFIX_.'page p ON pv.id_page = p.id_page 
                  LEFT JOIN '._DB_PREFIX_.'page_type pt ON p.id_page_type = pt.id_page_type 
                  WHERE pt.name = \'product\' AND p.`id_object` = '.intval($id_product).' group by pv.id_page'); 
                  return isset($view1['total']) ? $view1['total'] : 0; 
}
  • Like 1

Share this post


Link to post
Share on other sites

 

use this code:

 

 public static function getTotalViewed($id_product){ 
                 $view1 = Db::getInstance()->getRow('SELECT SUM(pv.counter) AS total FROM '._DB_PREFIX_.'page_viewed pv 
                  LEFT JOIN '._DB_PREFIX_.'page p ON pv.id_page = p.id_page 
                  LEFT JOIN '._DB_PREFIX_.'page_type pt ON p.id_page_type = pt.id_page_type 
                  WHERE pt.name = \'product\' AND p.`id_object` = '.intval($id_product).' group by pv.id_page'); 
                  return isset($view1['total']) ? $view1['total'] : 0; 
}

 

 

Hi Sandeep1186, was that to my request or the previouse post= If my request, in which file and where should this be placed? Thanks!

Share this post


Link to post
Share on other sites
  • 3 weeks later...

Hello , please , i need

 

(This feature uses default prestashop stats engine, so it mean, that it's necessary to turn on datamining module and enable all features for this addon (default module in your prestashop, you can turn on its features on module configuration page)

Share this post


Link to post
Share on other sites
  • 2 months later...

Hello,

 

Im using PS 1.6.0.9 and its 100% work.

The problem is, if everytime we refresh the product page, it count +1.

How to prevent it counting again with the same user (unique counter).

 

Any help would be appriciate.

 

Best regards

Share this post


Link to post
Share on other sites
  • 3 weeks later...

 

new working feature for prestashop 1.5.x and 1.6.x

free tutorial

 

I've noticed several times that many merchants asking about this feature for prestashop 1.5.x / 1.6.x

so here it is :) totally free and easy in use modification

 

enjoy!

 

product page views counter

product-page-views-count-prestashop.jpg

 

How to add a sum of all visitors to a home page?

 

Thank you.

Share this post


Link to post
Share on other sites
  • 2 weeks later...

HI Vekia, Thanks for all of the work and effort you put into the Prestashop community....I have learnt a lot from your posts.

 

Recently, I implemented your "PrestaShop product page visits counter" http://mypresta.eu/en/art/developer/product-page-visits-counter.html into my 1.6.0.9 Prestashop environment and it works great EXCEPT that the number that is displayed on the front office is always significantly less than what is displayed via the STATS section in the Back office.

 

For example, the front office displays "1" when the back office displays "62"!

 

The Datamining module has been installed for many months.... I have had a look around the tables in the database and found a table called ps_page_viewed that looks like it contains a count of the number of page views for a product per day.

 

I manually counted the records for product ID that was showing "62" and the total of the individual records in the database totaled "62"...so, is this where the issue is?

 

I would really like to use this feature and it would be greatly appreciated if you could have a look and provide a solution....

 

Thanks again Vekia

 

Regards Greg

Share this post


Link to post
Share on other sites
  • 2 weeks later...

Hi guys

 

After much googling and mucking around I have finally found a solution to the problem of the page views not being correct for 1.6.0.9 of Prestashop. The following query works on 1.6.0.9:

 

public static function getTotalViewed($id_product){
         $view1 = Db::getInstance()->getRow('SELECT SUM(pv.counter) AS total FROM '._DB_PREFIX_.'page_viewed pv
          LEFT JOIN '._DB_PREFIX_.'page p ON pv.id_page = p.id_page
          LEFT JOIN '._DB_PREFIX_.'page_type pt ON p.id_page_type = pt.id_page_type
          WHERE pt.name = \'product\' AND p.`id_object` = '.intval($id_product).' group by pv.id_page');
          return isset($view1['total']) ? $view1['total'] : 0;
}
 

Regards

Greg


Next question Vekia is how do I get the page views to display on the product image like you do in the example???

 

Regards

Greg

Share this post


Link to post
Share on other sites
  • 4 weeks later...

Hi vekia,

 

Can you tell me how to make this as a sql query in SQL Manager of prestashop 1.6.0.11 ?

In the stats I see the page views per product, but I have to click on each product to see the number of views.

I want the page view count per product and date (per week) in one list.

I've tried, but can't seem to get the right db connections and statements ;-)

 

Thanks if you can help me!!!

Edited by unlimitedgrain (see edit history)

Share this post


Link to post
Share on other sites
  • 1 year later...
  • 1 year later...

I managed to get the counter working on 1.7.2.4. 

Here is the code for FrontController.php:

    public static function getTotalViewed($id_product){ 
        
        $view1 = Db::getInstance()->executeS('SELECT pv.counter AS total FROM '._DB_PREFIX_.'page_viewed pv 
        LEFT JOIN '._DB_PREFIX_.'page p ON pv.id_page = p.id_page 
        LEFT JOIN '._DB_PREFIX_.'page_type pt ON p.id_page_type = pt.id_page_type 
        WHERE pt.name = \'product\' AND p.`id_object` = '.intval($id_product).''); 
        $totalviews = 0;
        for ($i=1;$i<=count($view1);$i++) {
            $totalviews += $view1[$i-1]['total'];
        }
        return $totalviews; 
      }

Code for Product.tpl remains the same (as in the tutorial from 1st post).

Edited by bTk (see edit history)

Share this post


Link to post
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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More