Page 1 of 3 123 LastLast
Results 1 to 10 of 25
  1. #1
    Join Date
    Jan 2008
    Posts
    43
    Plugin Contributions
    0

    Default Eliminating dual content due to missing cPath variable

    Good day,

    Some time ago I read about search engines seeing links with and without cPath as different links, seeing this as dual content, this being a bad thing.

    I don't know if that has been solved or not, but since I couldn't find anything about it and it was possible on my install I looked for a solution.

    I adjusted a piece of code someone else on this board put together for me (originally so I could redirect old incoming quick-cart links to the new zen-cart links).

    This code checks if a product_info link has a cPath, and if it doesn't it looks it up and redirects with a 301 moved permanently header.

    So far it seems to work, if anyone spots any problems with this system I'd love to hear about it.

    Code:
    if ($_GET['main_page'] == 'product_info' && !(isset($_GET['cPath'])) && isset($_GET['products_id']) && (int)$_GET['products_id'] > 0) {
      $iProducts_id = (int)$_GET['products_id'];
      Header( "HTTP/1.1 301 Moved Permanently" );
      zen_redirect(zen_href_link(zen_get_info_page($iProducts_id), 'cPath=' . zen_get_product_path($iProducts_id).'&products_id='.$iProducts_id));
    }
    There's probably tons of places to put this and it'll work, I just put it in index.php below:
    Code:
    /**
     * Load common library stuff 
     */
      require('includes/application_top.php');"
    Last edited by Diavire; 12 Jul 2008 at 12:25 PM.

  2. #2
    Join Date
    Jan 2008
    Posts
    43
    Plugin Contributions
    0

    Default Re: Eliminating dual content due to missing cPath variable

    Past the 7 minute editting time, just wanted to add that you should always backup and test rigorously before putting code on a live site.

    Good luck!

  3. #3
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Eliminating dual content due to missing cPath variable

    Your code doesn't take into consideration the issue of what to do when a product is linked to more than one category.

    Zen Cart v1.3.8 has the bulk, if not all, of the code using the same cpath and products_id ...
    Have you tried this to see if it would work for you?
    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!

  4. #4
    Join Date
    Jan 2008
    Posts
    43
    Plugin Contributions
    0

    Default Re: Eliminating dual content due to missing cPath variable

    I read a thread not too long ago where it turned out that a box in which products that were bought along with a certain product by other people were shown did not include the cPath (in 1.3.8), didn't see a solution posted for that yet, but I haven't really searched.

    I have tested this myself on 1.3.8 and it worked for me, didn't put it on our live site yet in case someone would reply with negative thoughts about the code, but I'll probably put it on tomorrow.

    I've tried it specifically with a linked product (because I read about the problems with that in the thread about the centerbox mentioned above), and it used the master category as cPath, I'll try it again with some other linked products, but I expect it grabs the master category's cPath by default. (if you think this won't be the case, or there are other potential problems I'd love to hear it, naturally)

    I can't think of any situations where our site would give a link without a cPath, but through Google Webmaster Tools I can see that there are some products indexed having a link with and without a cPath (they're shown as having duplicate meta tags \ titles), which is unwanted behavior, that's why I went for this.

    It comes down to this being possible with the current incarnation of zen-cart (if this comes from a bug in a mod or someone placing a link and taking out the cPath doesn't matter, it's possible), while (I think), this code makes accessing such a link impossible and redirects it to a complete link. That can only be a good thing, right?

  5. #5
    Join Date
    Jul 2007
    Posts
    154
    Plugin Contributions
    0

    Default Re: Eliminating dual content due to missing cPath variable

    Quote Originally Posted by Diavire View Post
    Good day,

    Some time ago I read about search engines seeing links with and without cPath as different links, seeing this as dual content, this being a bad thing.

    I don't know if that has been solved or not, but since I couldn't find anything about it and it was possible on my install I looked for a solution.

    I adjusted a piece of code someone else on this board put together for me (originally so I could redirect old incoming quick-cart links to the new zen-cart links).

    This code checks if a product_info link has a cPath, and if it doesn't it looks it up and redirects with a 301 moved permanently header.

    So far it seems to work, if anyone spots any problems with this system I'd love to hear about it.

    Code:
    if ($_GET['main_page'] == 'product_info' && !(isset($_GET['cPath'])) && isset($_GET['products_id']) && (int)$_GET['products_id'] > 0) {
      $iProducts_id = (int)$_GET['products_id'];
      Header( "HTTP/1.1 301 Moved Permanently" );
      zen_redirect(zen_href_link(zen_get_info_page($iProducts_id), 'cPath=' . zen_get_product_path($iProducts_id).'&products_id='.$iProducts_id));
    }
    There's probably tons of places to put this and it'll work, I just put it in index.php below:
    Code:
    /**
     * Load common library stuff 
     */
      require('includes/application_top.php');"
    Diavire,
    I have been looking for the solution to Google reported duplicate content for days... Thank you very much - your code seems to work perfectly.
    I can only tell that it does convert the multiple product urls without the "cPath" to the one with the "cPath" for each product (for any product on my site, including products with multiple category links). It is too early (I just implemented your code earlier today) if Google is going to remove duplicate content warnings for my site.

    I have one question however. Is there a way to actually see what search engine sees when it encounters one of the "HTTP/1.1 301 Moved Permanently" pages? I tried to look at the redirecting page code with a page snooper (utility from www.submitexpress.com) which is supposed to show you what Search Engine sees on your page but I couldn't find any header line with 301 redirect in it... How do I know search engine is really getting the 301 message? How does it work? Is the 301 redirect permanently command supposed to be "invisible"?

  6. #6
    Join Date
    Jul 2007
    Posts
    154
    Plugin Contributions
    0

    Default Re: Eliminating dual content due to missing cPath variable


  7. #7
    Join Date
    Jan 2008
    Posts
    43
    Plugin Contributions
    0

    Default Re: Eliminating dual content due to missing cPath variable

    Quote Originally Posted by Ajeh View Post
    Your code doesn't take into consideration the issue of what to do when a product is linked to more than one category.

    Zen Cart v1.3.8 has the bulk, if not all, of the code using the same cpath and products_id ...
    Have you tried this to see if it would work for you?
    I've now put it live on my site, tested with some other linked products and it uses the main category for cPath in all cases, so far so good. I'd like to hear back from you wether or not using this is a good idea or not and for what reasons.

    Maybe you also have some thoughts on what could be going wrong for all4coffee below?

    Quote Originally Posted by all4coffee View Post
    Glad you're happy with the code, but there seem to be some problems... somewhere...

    First off, the first link seems to have an incomplete cPath? When following the second link it redirects to cPath 6_19, while the first link is just 19, did you mean to post it like that?

    Basically, the cPath 19 is a problem, because since a cPath is given, the code doesn't think twice about it and doesn't check if the cPath is actually correct.
    You could code around that and make it check the cPath even if one is given, but I don't know how heavy that's going to be on the server...

    Secondly, when checking my headers using this code, I get a 301 Moved Permanently. When checking the redirect on your site, you get a 301 OK. That's not right. For a normal page you're supposed to get a "200 OK", for a permanent redirect that's "301 Moved Permanently", this is some weird combination of the two. I'd think that's something you need to contact your hoster about, because search engines aren't getting the right header, or even a valid one, when redirecting now.

  8. #8
    Join Date
    Jan 2008
    Posts
    43
    Plugin Contributions
    0

    Default Re: Eliminating dual content due to missing cPath variable

    BTW, forgot, you can check your headers by googling "header check", that'll give you a bunch of pages that'll show you what your site is reporting.

  9. #9
    Join Date
    Oct 2006
    Location
    Alberta, Canada
    Posts
    4,571
    Plugin Contributions
    1

    Default Re: Eliminating dual content due to missing cPath variable

    Diavire, here are the results of some testing I did, on the http://www.all4coffee.com/ site.

    For the most part, everything below would apply to any Zen Cart site.

    The URLs have been shortened for easier readability.


    Sub-category Link
    main_page=index&cPath=6_19
    - Loose Tea Blends


    Product Link
    main_page=product_info&cPath=6_19&products_id=97
    - European Blend Tea


    All Listings
    main_page=products_all&disp_order=1&page=5
    - European Blend Tea is 7th on the page

    Note: In this case the "All Listings" will always show a Product Page URL without a 'cPath', such as:
    main_page=product_info&products_id=97
    - don't think it is supposed to be that way though?


    The following 'unknown' links all show "European Blend Tea"
    main_page=product_info&cPath=6&products_id=97
    main_page=product_info&cPath=19&products_id=97

    As to how a SE will find the above 2 'unknown' links, I don't know.


    IMHO, all the above is just more reasons why people should not worry about Duplicate Content.

    Reference: Duplicate content

    Duplicate content generally refers to substantive blocks of content within or across domains that either completely match other content or are appreciably similar. Mostly, this is not deceptive in origin. Examples of non-malicious duplicate content could include:

    * Discussion forums that can generate both regular and stripped-down pages targeted at mobile devices
    * Store items shown or linked via multiple distinct URLs
    * Printer-only versions of web pages


    And, as to the 301 OK msg., not a big deal. That's just how an MS Server operates. The number is what's important to Servers/Software and the following Text msg. is for us Humans.
    Last edited by Website Rob; 15 Jul 2008 at 12:49 PM.

  10. #10
    Join Date
    Jan 2008
    Posts
    43
    Plugin Contributions
    0

    Default Re: Eliminating dual content due to missing cPath variable

    Thanks for taking a closer look ;)

    You're right in assuming the all products section shouldn't show links without cPaths, maybe he's using an old version of zen-cart? In any case, our site does show cPaths in that section.

    The redirecting code does seem to be doing its work though, as all products I tried end up with a cPath.

    It's also correct that both those links show European Tea Blend, as zen-cart only looks for the product id to show the product in question, you could set a cPath of eleventy trillion, and if that number matches a category it'll show the product to be in that category. You could make a plastic model kit show up in a wooden model kit category, just by changing the cpath, but that's of course not where you want it ;)

    This also gives problems when you click the Category List button in a product, as you wind up in the wrong category.

    How a SE would find those links is indeed a bit mysterious :P

    It's probably true that Google doesn't care as much in this type of case, so likely no reason to worry, but if you can have your affairs in order, why not do so? :)

    Thanks for the MS server bit, I didn't know that >)

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. v151 Need help w/ variable flat rate shipping due to item size
    By ogre in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 14 Oct 2013, 09:34 PM
  2. v150 COWOA forgot password fails due to missing function
    By geeker in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 2 Nov 2012, 06:01 AM
  3. Replies: 2
    Last Post: 20 Nov 2008, 07:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg