Forums / General Questions / Products Viewed - Exclude Spiders

Products Viewed - Exclude Spiders

Results 1 to 11 of 11
26 Feb 2011, 16:26
#1
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Posts:
968
Plugin Contributions:
0

Products Viewed - Exclude Spiders

Hi all,

Does anyone know if it's possible to stop spiders from incrementing the products viewed entries?

I would really like to know what my customers are looking at not the spiders..

Cheers,
Phil
26 Feb 2011, 16:48
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Posts:
62,757
Plugin Contributions:
1

Re: Products Viewed - Exclude Spiders

The counter is in the:
/includes/modules/pages/product_info/main_template_vars.php

You should be able to surround that with an IF so that spiders are not counted:
if ($spider_flag == false) {
// products_viewed code
}
26 Feb 2011, 17:01
#3
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Posts:
968
Plugin Contributions:
0

Re: Products Viewed - Exclude Spiders

Ajeh:

The counter is in the:
/includes/modules/pages/product_info/main_template_vars.php

You should be able to surround that with an IF so that spiders are not counted:
if ($spider_flag == false) {
// products_viewed code
}




will this do it? want to check first, dont want to break it..

if ($spider_flag == false) {
$res = $db->Execute($sql);
}


?
26 Feb 2011, 17:04
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Posts:
62,757
Plugin Contributions:
1

Re: Products Viewed - Exclude Spiders

If you have that on the one under the select for:
    $sql = "update " . TABLE_PRODUCTS_DESCRIPTION . "
            set        products_viewed = products_viewed+1
            where      products_id = '" . (int)$_GET['products_id'] . "'
            and        language_id = '" . (int)$_SESSION['languages_id'] . "'";
    if ($spider_flag == false) {
      $res = $db->Execute($sql);
    }


Then it should work ...

Be sure to test this and see how well the changes work for you and that it still counts guests and customers ...
26 Feb 2011, 17:09
#5
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Posts:
968
Plugin Contributions:
0

Re: Products Viewed - Exclude Spiders

Yeah I did this:

[PHP]//added to stop spiders incrementing
if ($spider_flag == false) {

$sql = "update " . TABLE_PRODUCTS_DESCRIPTION . "
set products_viewed = products_viewed+1
where products_id = '" . (int)$_GET['products_id'] . "'
and language_id = '" . (int)$_SESSION['languages_id'] . "'";

$res = $db->Execute($sql);

}
//added to stop spiders incrementing[/PHP]

seems to be working for customers/visitors just watching for spiders now :o)
26 Feb 2011, 17:14
#6
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Posts:
968
Plugin Contributions:
0

Re: Products Viewed - Exclude Spiders

couldn't be bothered to wait, fetched as googlebot from webmaster tools and no increment so seems to work a treat :)

Surprised this isnt already built in!

Thanks

Phil
26 Feb 2011, 17:36
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Posts:
62,757
Plugin Contributions:
1

Re: Products Viewed - Exclude Spiders

Thanks for confirming that this worked for you ...

Some may want to know all counts ...

Personally, I'd like to see a count for spiders separate from the guest/customers ... but that is just me ...:cool:
26 Feb 2011, 19:26
#8
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Posts:
968
Plugin Contributions:
0

Re: Products Viewed - Exclude Spiders

Ajeh:

Thanks for confirming that this worked for you ...

Some may want to know all counts ...

Personally, I'd like to see a count for spiders separate from the guest/customers ... but that is just me ...:cool:


Yeah could add an additional column in the table and have the second query run on the opposite logic to the if statement and then have the report show both.

I agree as it's still important to see that spiders are crawling all products so is an easy reference to check this.

Phil :)
07 Jan 2013, 16:35
#9
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Posts:
10,011
Plugin Contributions:
1

Re: Products Viewed - Exclude Spiders

Ajeh:

Thanks for confirming that this worked for you ...

Some may want to know all counts ...

Personally, I'd like to see a count for spiders separate from the guest/customers ... but that is just me ...:cool:
I HATE to bump an old post.. But how could this separate count be implemented??
07 Jan 2013, 22:27
#10
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Posts:
62,757
Plugin Contributions:
1

Re: Products Viewed - Exclude Spiders

The basic idea is that there is a flag set for:
$spider_flag

so when the Counter tables are updated, you would do one thing for spiders and one thing for none spiders ...
14 Sep 2013, 11:49
#11
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Posts:
1,326
Plugin Contributions:
0

Re: Products Viewed - Exclude Spiders

Bringing this thread to life again. I there any way to get this working in v1.51?

the update of the products viewed count now appears to be in \classes\observers\class.products_viewed_counter.php as

function update(&$class, $eventID, $paramsArray = array())
  {
    if ($eventID == 'NOTIFY_PRODUCT_VIEWS_HIT_INCREMENTOR')
    {
      if (defined('LEGACY_PRODUCTS_VIEWED_COUNTER') && LEGACY_PRODUCTS_VIEWED_COUNTER == 'on')
      {
        global $db;
        $sql = "update " . TABLE_PRODUCTS_DESCRIPTION . "
                set        products_viewed = products_viewed+1
                where      products_id = '" . (int)$paramsArray . "'
                and        language_id = '" . (int)$_SESSION['languages_id'] . "'";
        $res = $db->Execute($sql);
      }
    }
  }
  }



I've added the spider_flag like so

      {
        global $db;
		if ($spider_flag == false) {
        $sql = "update " . TABLE_PRODUCTS_DESCRIPTION . "
                set        products_viewed = products_viewed+1
                where      products_id = '" . (int)$paramsArray . "'
                and        language_id = '" . (int)$_SESSION['languages_id'] . "'";
        $res = $db->Execute($sql);
		}
      }
    }
 


but it has no effect on the view counter increment. No doubt something a little bit smarter is needed.