Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Add Top Category in SEO URLs OSC2.2


steeevo

Recommended Posts

I've just started reorganizing one of my websites products categories which relies heavily on the order of the categories for SEO purposes.  
in the SEO URLs config options there is an option in there that says" Add category parent to begining of URLs?"  which I have set to true. 

in the past I've only have 2 levels of categories so it behaved as expected creating URLs as such:

http://webiste.com/main-category-sub-category1-c-1.html

however I've added another level of categories and would like the URL to read as such:

http://webiste.com/main-category-sub-category1-sub-category2-c-1.html

 

but I'm getting:

http://webiste.com/sub-category1-sub-category2-c-1.html

it only pulls in the parents category name one level up.. not all the way to the top. 

I have found in the seo.class.php file the following code which I believe controls this url structure which reads as so:

 

 
case ($this->attributes['SEO_ADD_CAT_PARENT'] == 'true'):
                                                $sql = "SELECT c.categories_id, c.parent_id, cd.categories_name as cName, cd2.categories_name as pName
                                                                FROM ".TABLE_CATEGORIES." c
                                                                JOIN ".TABLE_CATEGORIES_DESCRIPTION." cd
                                                                ON c.categories_id = cd.categories_id
                                                                LEFT JOIN ".TABLE_CATEGORIES_DESCRIPTION." cd2
                                                                ON c.parent_id=cd2.categories_id AND cd2.language_id='".(int)$this->languages_id."'
                                                                WHERE c.categories_id='".(int)$single_cID."'
                                                                AND cd.categories_id='".(int)$single_cID."'
                                                                AND cd.language_id='".(int)$this->languages_id."'
                                                                LIMIT 1";
                                                $result = $this->DB->FetchArray( $this->DB->Query( $sql ) );
                                                $cName = $this->not_null($result['pName']) ? $result['pName'] . ' ' . $result['cName'] : $result['cName'];
                                                break;

Can anyone help me modify the code so the URL structure is what I'm needing?
Thanks ahead of time for the help

Link to comment
Share on other sites

The full parent parent path is in the url if the product is reached by clicking to it. That is, if you click on category A and then on its sub-category B and then the product, the url will a-b in it. But if you go directory to a product through something like the what's new box, only the immediate category will show. You will need to add a function to get the path of category ID's along with their names and build the string from that. That could slow the response time down quite a bit and may not be correct if you have linked products. I suggest leaving it as it is and using the google XML sitemap addon to let the search engines know where to look.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

when I view a product, the url is made up of the products title and no categories are listed with it. which is fine. This is what I want. my concern is only with subcategories. 
the site map is irrelevant being that my main concern is that i want all parent categories used in sub categpry urls. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...