Why a product has multiple links and can show under different categories???
[Note: remember to include site URL, ZC version, list of plugins, PHP version, etc ... read the Posting Tips shown above for information to include in your post here. And, remove this comment before actually posting!]
In Zen cart product's URL should in format like this :
https://domain.com/index.php?main_page=product_info&cPath=42&products_id=9553
I got this link because I created the product with ID 9553 ONLY under category with ID 42.
However, I found if I twisted the url a little by changing the category id to 38 , which represents another category, the link still works!
and it shows the product 9553 under category 38, even I have never created the product or link the product there!
To search engine it means the product has multiple copies of url, since I have multiple categories.
Anybody can tell me how to fix the problem?
Re: Why a product has multiple links and can show under different categories???
For example, I created a product with ID 8066 under category with ID 38, the product URL will be generated like:
https://solutiontestbank.com/index.p...oducts_id=8066
but if I changed the cpath=38 to cpath =42, for example like the following,
https://solutiontestbank.com/index.p...oducts_id=8066
it still shows the product , but under category 42 and this is NOT right!
What I want: when url is wrong, it should show "page not found"
Re: Why a product has multiple links and can show under different categories???
Your assumption is that the search engines are going to change category ids in your urls to see if they can discover something that doesn't exist... nope they are not going to do that, so it is a non issue. When you manually change the cpath in the url it gets ignored by the cart and you get taken to the product based on the product id parameter.
Re: Why a product has multiple links and can show under different categories???
Also remember a product can be in many categories if it's a Linked Product. Having the category id in the URL just means you can navigate through that category with the Next and Prev buttons on your product info page, assuming your template has them and they are enabled.
Re: Why a product has multiple links and can show under different categories???
Put another way, although the product does/can show under multiple categories either on purpose (linked product) or by someone attempting an alternate category (say the product is now in category 42, someone store's that link, and then later it is mapped to (linked) to category 38), the product is identified to a master category and as a result the canonical link should show the master category. By the canonical link identifying the product as belonging to category 42, regardless the entered cPath value, the product is seen as being a single product having multiple ways to get to it.
The cPath is an indicator of association to the product, it doesn't uniquely identify the product. The products_id is what uniquely identifies the product. If a product exists under one category now and is then moved (not necessarily linked) to another category and the request is implemented, instead of the product being located and the new canonical link provided, the product will be identified as no longer existing and need to be found again by either users or search engines.
Now, because you indicated that your site is using Zen Cart version 1.5.1, released nearly 7 years ago, if you by chance are using the now recommended all https: style of access, the above discussed canonical link will not be present and could be a reason that you may come across issues. As of production released version 1.5.3, if the site was made all https: by this instruction: https://www.zen-cart.com/content.php...alled-zen-cart then the canonical link would be provided on https: pages.
I personally don't recommend implementing the requested change, but it's not my site.
I would think that the best place to incorporate the desired change would be in includes/init_includes/init_sanitize.php
Towards the end of the file is a check to validate products_id for search engines and bookmarks, etc.
Within that section, if you are going to implement a product not found type action then would suggestevaluating the provided cPath to see if the product is found in that category and if not to do the redirect to the product not found page. Understand though also that such search on each product page will use additional resources to validate the information being compared. Further also note that while the cPath was called into question, there also is a similar "difference" possibly seen by using a different main_page parameter value. For example you showed product_info; however, the product would likely still show if document_product_info or say perhaps product_free_shipping_info.
Re: Why a product has multiple links and can show under different categories???
Thank you for your reply.
I found the problem when I was trying to fix the "Duplicate without user-selected canonical“ problem in google search console.
In "Duplicate without user-selected canonical" tab of google search console,
there are many links of such things with wrong category ID,
for example "https://domain.com/index.php?main_page=product_info&cPath=47&products_id=3972", the right url and submitted in sitemap is
"https://domain.com/index.php?main_page=product_info&cPath=29&products_id=3972"
This is not rare example, there are thousands of links with wrong category id and were marked duplicates in my account.
The product is only created under category 42, it is Never linked to any other category like 47, and its canonical link confirms this, but in the URL it says 47 so it is a wrong one. the link is not provided in my sitemap either, google said the "URL might be known from other sources that are currently not reported" I have no idea where it came from. but it is visitable, as a matter of fact, googlebot saw this, and took it a duplicate one, I need it to return a 404 error to eliminate duplicate problem.
Re: Why a product has multiple links and can show under different categories???
Thank you, I fully aware of that. A product can be shows up in multiple categories, provided you manage this in admin since there is such function.
But I only created the product ONLY under one category, have NEVER linked it to other categories.
Also, the problem I mentioned above actually created thousands of duplicate or triplicate links
Re: Why a product has multiple links and can show under different categories???
Can you please help me with the following question?
If I created a product 1 under category 42 and has never linked to another categories, system will generated link like:
https://domain.com/index.php?main_page=product_info&cPath=42&products_id=1
The cpath=42 indicates its mastercategory and products_id=1 indicates it is the specific product itself, right?
If somebody changed 42 to other number , for example , 38, make it as https://domain.com/index.php?main_pa...&products_id=1
even it is not mapped to category 38, but the same product page still visitable, and product page shows up under category 38, is this normal ?
does anybody's zen site work like this? or Zen cart is intentional designed in this way?
Re: Why a product has multiple links and can show under different categories???
mc12345678
The product I mentioned above has never moved, or mapped, or linked to any other category.
If you created a test product with ID 1 under category 2, system gives you
"https://domain.com/index.php?main_page=product_info&cPath=2&products_id=1
is that right? for example , I have 10 different categories with different id numbers, 2 to 12
My problems is:
when I only submit one unique link in sitemap to google search console but for some reason, googlebot can literally crawl 10 copies of DIFFERENT urls and they return the same product info page. for example:
https://domain.com/index.php?main_pa...&products_id=1 (right one and I submitted and confirmed in its canonical tag in header)
https://domain.com/index.php?main_pa...&products_id=1
https://domain.com/index.php?main_pa...&products_id=1
https://domain.com/index.php?main_pa...&products_id=1
https://domain.com/index.php?main_pa...&products_id=1
https://domain.com/index.php?main_pa...&products_id=1
...........
https://domain.com/index.php?main_pa...&products_id=1
They are all visitable and shows under different categories and make it looks like I linked , or ever moved, or mapped there but NO, I have never done that. this is crazy, I am wondering why and how google found these links, but google says, "URL might be known from other sources that are currently not reported" I have no idea about the sources. I don't have control over the sources, all I want is when google visit those wrong links, it can generate "page not found" error or 410 error sth like that.
Re: Why a product has multiple links and can show under different categories???
I used to use Ceon MAPPING but recently it was turned off. when the CEON MAPPING WAS ON, I don't have this problem, since all urls were in readable format, so there is such problem.