Forums / Templates, Stylesheets, Page Layout / $current_category_id incorrect on product page

$current_category_id incorrect on product page

Views: 2,698

Results 1 to 9 of 9
22 Jul 2009, 9:19 AM
#1
andy_gs avatar

andy_gs

Zen Follower

Join Date:
Jun 2008
Posts:
187
Plugin Contributions:
0

$current_category_id incorrect on product page

Hey guys,
I have a problem with zencart defaulting to 'master category id' on a product page.
for some reason our cart doesn't seem to follow the true path of $current_category_id.

From a fresh install it seems that the $current_category_id is adeared to when clicking through to a product page.

my problem is this
e.g.

i have product 235 - its in category 6(master) and category 7.

I navigate from category 6 to the product and $current_category_id = 6 -Which is correct.

I navigate from category 7 to the product page and $current_category_id = 6 - Which is incorrect.

and weirder still the url structure takes the last place the product was copied to regardless of if the product came from the master category page.

so for example product 789 is in category 111(master), 222, 333. I copied the product last to cat 333.

I navigate from 111 to product and Url structure would be /shop/333/789.html.

I navigate from 222 to product and Url structure would be /shop/333/789.html.

I navigate from 333 to product and Url structure would be /shop/333/789.html.

Clearly its somthing that has been messed about with before i arrived here, because its always done this and only now is it affecting functionality where i need 'current_category_id' to be correct so that my custom nav shows only in a certain category.

At category level my custom nav shows fine because 'current_category_id' is still being adeared to but then when i click on the product from this cat it doesn't display my custom nav.

guys i really need help with this, i just have no clue where to start.

regards

Andy.

oh dear gurrrddddd.

22 Jul 2009, 6:29 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: $current_category_id incorrect on product page

Zen Cart doesn't normally create URLs in the form of "/shop/333/789.html", so those URLs must be getting altered by a so-called SEO addon.

Is there something wrong with your addon?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

23 Jul 2009, 9:11 AM
#3
andy_gs avatar

andy_gs

Zen Follower

Join Date:
Jun 2008
Posts:
187
Plugin Contributions:
0

Re: $current_category_id incorrect on product page

I've often asked this question but as i wasn't around when this module was installed i'm reluctant to tinker with it.

But surely the seo module shouldn't be affecting the '$current_category_id' and even if it was it would mean it should default to the 'master category id' url.

But Dr i think you may well be right about the seo module being broken to some extent, i just have to work out which of the two is being used. it's either 'ultimate-seo' or its 'magic-seo' is there a way to tell which one is being used?

regards

Andy.

oh dear gurrrddddd.

23 Jul 2009, 4:52 PM
#4
ajeh avatar

ajeh

Oba-san

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

Re: $current_category_id incorrect on product page

I would check if you have a switch to turn those off or something and then look at the Known Bug Fixes for v1.3.8 at:
http://www.zen-cart.com/forum/showthread.php?p=610860#post610860

and review the ones on master_categories_id or categories_id or cpath that have been posted to see if that clears up the problem ...

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!

24 Jul 2009, 8:52 AM
#5
andy_gs avatar

andy_gs

Zen Follower

Join Date:
Jun 2008
Posts:
187
Plugin Contributions:
0

Re: $current_category_id incorrect on product page

Hello thanks for replying i've corrected:

Problem: Sales made with Salemaker having trouble on some sales with Linked Products ...

Problem: Looking up fields in products and products_description and looking up fields in categories and categories_description ...

Problem: Lookup of fields in products or products_description by products_id in the Admin

Symptom:
There's a bug in v1.3.8 which only shows when you have
Admin->Configuration->Layout Settings->Categories - Always Show on Main Page = 1

However none of these seemed to have fixed the issue.

Any other ideas?

Andy.

oh dear gurrrddddd.

24 Jul 2009, 1:58 PM
#6
ajeh avatar

ajeh

Oba-san

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

Re: $current_category_id incorrect on product page

Turn off the SEO to see if this is contributing to the problem ...

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!

24 Jul 2009, 3:52 PM
#7
andy_gs avatar

andy_gs

Zen Follower

Join Date:
Jun 2008
Posts:
187
Plugin Contributions:
0

Re: $current_category_id incorrect on product page

Heya ajeh,

i've found out 2 things

  1. we have magic-seo installed

  2. its this thats knocking it out.

when i temporarly removed this the 'current_category_id' worked correctly and also my orginal 'cpath' method for including my nav worked as well.

Next step for me is contacting them ill update here with the outcome for the benefit on any other people who are encountering this problem

regards

Andy.

oh dear gurrrddddd.

24 Jul 2009, 4:26 PM
#8
ajeh avatar

ajeh

Oba-san

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

Re: $current_category_id incorrect on product page

Thanks for the information that your SEO is the issue ... let us know what you find out ... :smile:

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!

5 Mar 2011, 8:28 PM
#9
templs avatar

templs

New Zenner

Join Date:
Dec 2010
Posts:
3
Plugin Contributions:
0

Re: $current_category_id incorrect on product page

I've got the same trouble as topic starter has.
I didn't found any solution on this forum. I've googled hard and as a result I've found this:
ddmin.com/zen-cart_zen_get_products_category_id-bug/
It is in Chinese, but google translated it pretty well:
translate.google.com/translate?js=n&prev=_t&hl=en&ie=UTF-8&layout=2&eotf=1&sl=auto&tl=en&u=http%3A%2F%2Fwww.ddmin.com%2Fzen-cart_zen_get_products_category_id-bug%2F

But in my situation variable $current_category_id wasn't NULL, but 4.
In this case I didn't found anything better than disabling IF.
So my zen_get_products_category_id function looks so:

  function zen_get_products_category_id($products_id) {
    global $db;

/* ori
    $the_products_category_query = "select products_id, master_categories_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'";
    $the_products_category = $db->Execute($the_products_category_query);

    return $the_products_category->fields['master_categories_id'];
*/
//bof category icon display fix, by Yury
//if (! $the_products_category->fields['master_categories_id']) {
    $d_p2c_cid = $db->Execute('SELECT categories_id FROM `' . TABLE_PRODUCTS_TO_CATEGORIES . '` WHERE products_id="' . $products_id . '"')->fields['categories_id'];
    $the_products_category->fields['master_categories_id'] = $d_p2c_cid;
//echo $d_p2c_cid;
//}
    return $d_p2c_cid;
//eof category icon display fix, by Yury
  }

The site is Ok now, there are no secretes with that. Here I am - http://cellchaos.com

I'm tired with this fix, and now I don't wish to find out why my $current_category_id wasn't NULL
Please let me know if there are better solutions...