Forums / General Questions / Products Viewed - Exclude Spiders

Products Viewed - Exclude Spiders

Views: 1,379

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

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
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

Phil Rogers
A problem shared is a problem solved.

26 Feb 2011, 4:48 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
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
}

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

26 Feb 2011, 5:01 PM
#3
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
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);
}

 
?

Phil Rogers
A problem shared is a problem solved.

26 Feb 2011, 5:04 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
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 ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

26 Feb 2011, 5:09 PM
#5
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Products Viewed - Exclude Spiders

Yeah I did this:

//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

seems to be working for customers/visitors just watching for spiders now :o)

Phil Rogers
A problem shared is a problem solved.

26 Feb 2011, 5:14 PM
#6
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
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

Phil Rogers
A problem shared is a problem solved.

26 Feb 2011, 5:36 PM
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
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:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

26 Feb 2011, 7:26 PM
#8
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
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 :)

Phil Rogers
A problem shared is a problem solved.

7 Jan 2013, 4:35 PM
#9
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

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??

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

7 Jan 2013, 10:27 PM
#10
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
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 ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

14 Sep 2013, 11:49 AM
#11
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
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.

Simon