Post by christopherdarling » Mon Mar 15, 2010 6:55 am

Hi everyone,

I'm currently developing a site for a client of mine who sells Beads. We're facing a problem with the SEO keywords. For example we have the following Category structure:

+ Beads
- 6mm
- 8mm
- 12mm

In each of these categories we're adding a product named "Vegetable Ivory". And wanting the SEO Keyword to be vegetable-ivory. Sadly it only will display one of the products because the SEO Keyword is the same, although the product be in a different category.

Is there no way of having hierarchical URL's so we could have the following

.com/beads/6mm/vegetable-ivory/
.com/beads/8mm/vegetable-ivory/
.com/beads/12mm/vegetable-ivory/

As you can see, in this instance there's a need for this kind of support. Not just to grab the page via from the last section of the url. But to take the parent sections (i.e. categories) into consideration first.

Hope this explains the situation well enough, but any questions ask away and hopefully I'll re-explain better.

Thanks in adv.

Christopher Darling - Web Design Bristol


New member

Posts

Joined
Sat Jan 02, 2010 12:26 am

Post by rph » Mon Mar 15, 2010 11:08 am

SEO URLs need to be unique. The simplest solution is to just tack the extra information or a manufacturer item code to it.

.com/6mm-beads/6mm-vegetable-ivory
.com/6mm-beads/vegetable-ivory-sku1698523

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by christopherdarling » Mon Mar 15, 2010 5:15 pm

I understand the SEO Keyword for each product&category needs to be unique. But what I'm after is the SEO tool to be improved. If the SEO Tool was to consider the parent sections of the url, then each of the following would be classed as a unique URL.

.com/beads/6mm/vegetable-ivory/
.com/beads/8mm/vegetable-ivory/
.com/beads/12mm/vegetable-ivory/

Christopher Darling - Web Design Bristol


New member

Posts

Joined
Sat Jan 02, 2010 12:26 am

Post by rph » Mon Mar 15, 2010 6:07 pm

How?

I think you're looking at this backwards by thinking of it as a single string rather than parts that represent something else. It's not:

.com/beads/6mm/vegetable-ivory/

It's:

.com/category_id/category_id/product_id/

So basically you're asking for multiple products that all use the same product_id.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by christopherdarling » Tue Mar 16, 2010 1:16 am

Yes, this is very common. Alot of CMS's / eCommerce platforms support this.

I understand how the current system works. I'm after it to be improved. The url is a string, the code splits this up into sections by the delimeter '/' forming an array of 'sections'. The system only takes into consideration the last section (in this case, the product SEO Keyword). Ignoring any previous 'sections'.

I believe this can be achieved by creating a table for the seo keywords, which contains the following fields.

id, parent_id, id, seo_keyword

This can be used to store the data for categories and products. i.e.

beads cat id = 4
6mm cat id = 6
12mm cat id = 12
product id = 99

parent_id, id, seo_keyword
------------------------------------
0, 4, beads
4, 6, 6mm
4, 12, 12mm
6, 99, vegetable-ivory
12, 99, vegetable-ivory


I'd love to hear Daniels thoughts on this...

Christopher Darling - Web Design Bristol


New member

Posts

Joined
Sat Jan 02, 2010 12:26 am

Post by rph » Tue Mar 16, 2010 2:42 am

I think you're still not grasping how OpenCart builds and parses its URLs. Certainly how other shops do it has absolutely no bearing.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by christopherdarling » Tue Mar 16, 2010 5:56 am

I completely understand how OpenCart parses it's urls. It splits the url string by the slashes, uses the last segment from the array and looks this up in the Database. Ignoring any of the category seo keywords.

Christopher Darling - Web Design Bristol


New member

Posts

Joined
Sat Jan 02, 2010 12:26 am

Post by rph » Tue Mar 16, 2010 8:02 am

Nope. Categories are not ignored. If they were OpenCart would never be able to generate breadcrumbs, especially with products being able to belong to multiple categories.

/catalog/controller/common/seo_url.php

OpenCart is using the keyword to swap out for appropriate category_id, product_id, information_id and manufacturer_id.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by christopherdarling » Tue Mar 16, 2010 5:40 pm

seo_tool.php

Code: Select all

if (isset($this->request->get['product_id'])) {
                                $this->request->get['route'] = 'product/product';
If the url contains a product id, then the product controller is used to load the page.

product/product.php

Code: Select all

                if (isset($this->request->get['product_id'])) {
                        $product_id = $this->request->get['product_id'];
                } else {
                        $product_id = 0;
                }
                
                $product_info = $this->model_catalog_product->getProduct($product_id);
Where's the category id used there then?

Christopher Darling - Web Design Bristol


New member

Posts

Joined
Sat Jan 02, 2010 12:26 am

Post by rph » Wed Mar 17, 2010 12:45 am

Oh man, you're embarrassing yourself.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by christopherdarling » Thu Mar 18, 2010 4:46 pm

..prove it? happy to be proved wrong

Christopher Darling - Web Design Bristol


New member

Posts

Joined
Sat Jan 02, 2010 12:26 am

Post by MWYS » Thu Mar 18, 2010 5:15 pm

rph wrote:Oh man, you're embarrassing yourself.
In terms of resolving to the correct Product, christopherdarling is correct - Everything except the last URI segment is ignored (I.e, everything except the Product SEO Keyword). The parts before that have absolutley no affect other than they are there for Google / SEO Purposes, you can test this by going to a product, and when you see the category name in the URL change the category name to something random and the correct product will still load because the last segment of the URL is the product SEO Keyword which is what is used.

New member

Posts

Joined
Wed Oct 21, 2009 9:04 pm

Post by rph » Fri Mar 19, 2010 12:23 am

christopherdarling wrote:..prove it? happy to be proved wrong
/catalog/controller/common/seo_url.php

Code: Select all

                        foreach ($parts as $part) {
                                $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE keyword = '" . $this->db->escape($part) . "'");
                                
                                if ($query->num_rows) {
                                        $url = explode('=', $query->row['query']);
                                        
                                        if ($url[0] == 'product_id') {
                                                $this->request->get['product_id'] = $url[1];
                                        }
                                        
                                        if ($url[0] == 'category_id') {
                                                if (!isset($this->request->get['path'])) {
                                                        $this->request->get['path'] = $url[1];
                                                } else {
                                                        $this->request->get['path'] .= '_' . $url[1];
                                                }
                                        }       
                                        
                                        if ($url[0] == 'manufacturer_id') {
                                                $this->request->get['manufacturer_id'] = $url[1];
                                        }
                                        
                                        if ($url[0] == 'information_id') {
                                                $this->request->get['information_id'] = $url[1];
                                        }       
                                }
                        }
/catalog/controller/product/product.php

Code: Select all

        if (isset($this->request->get['path'])) {
                        $path = '';
                                
                        foreach (explode('_', $this->request->get['path']) as $path_id) {
                                $category_info = $this->model_catalog_category->getCategory($path_id);
                                
                                if (!$path) {
                                        $path = $path_id;
                                } else {
                                        $path .= '_' . $path_id;
                                }
                                
                                if ($category_info) {
                                $this->document->breadcrumbs[] = array(
                                                'href'      => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $path),
                                        'text'      => $category_info['name'],
                                        'separator' => $this->language->get('text_separator')
                                );
                                }
                }                       
        }

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by rph » Fri Mar 19, 2010 1:33 am

MWYS wrote:In terms of resolving to the correct Product, christopherdarling is correct - Everything except the last URI segment is ignored (I.e, everything except the Product SEO Keyword). The parts before that have absolutley no affect other than they are there for Google / SEO Purposes
You're confusing what OpenCart needs to load a product (a unique product_id/url_alias) with what it can actually use. Like I said, category_id is used to create breadcrumbs. Set it to a nonsensical category route and you'll see:

http://demo.opencart.com/index.php?rout ... duct_id=48

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by christopherdarling » Fri Mar 19, 2010 4:47 am

So like I said, cat_id / cat url_keyword is completely ignored when loading the product page. Not disputing it being used for the breadcrumbs.. but that's not what this topic is about

Christopher Darling - Web Design Bristol


New member

Posts

Joined
Sat Jan 02, 2010 12:26 am

rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by christopherdarling » Fri Mar 26, 2010 8:07 am

..not going to get anywhere with you..


Daniel, Q?...

Christopher Darling - Web Design Bristol


New member

Posts

Joined
Sat Jan 02, 2010 12:26 am

Post by rph » Fri Mar 26, 2010 2:19 pm

Well, what would you suggest then? Any system should:

1) Maintain category information for propagating breadcrumbs and category search filtering,
2) Account for a product being listed in multiple (sub)categories, and
3) Allow for the store to run with and without SEO URLs concurrently.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by Chris P Duck » Fri Mar 26, 2010 6:52 pm

The last segment of the URL should be unique, otherwise you'll run into problems with mod_rewrite because it's essentially mapping 1 string to 1 product.

You also need to keep in mind that search engines penalise you for duplicate content (see http://googlewebmastercentral.blogspot. ... ntent.html) so having the same product in multiple categories can be a bad idea as most of the content on the page will be the same.

If you're selling a product which comes in 3 sizes, it's really just 1 product with 3 "attributes" so I don't see why you should have 3 URL's to it that describe the size.

I'm working on something for Opencart at the moment which generates a unique SEO keyword for each product by checking the database for existing keywords as the default installation doesn't seem to do this and won't flag up an error when adding a product if the SEO keyword exists. Has anyone looked into this before?

Newbie

Posts

Joined
Fri Mar 19, 2010 12:24 am

Post by rph » Sat Mar 27, 2010 8:16 am

Chris P Duck wrote:You also need to keep in mind that search engines penalise you for duplicate content (see http://googlewebmastercentral.blogspot. ... ntent.html) so having the same product in multiple categories can be a bad idea as most of the content on the page will be the same.
There's been a bit of discussion about using canonical URLs to deal with the issue.
I'm working on something for Opencart at the moment which generates a unique SEO keyword for each product by checking the database for existing keywords as the default installation doesn't seem to do this and won't flag up an error when adding a product if the SEO keyword exists. Has anyone looked into this before?
Not that I'm aware of. The current version is a little rough. It doesn't even check for illegal characters in the URL alias which has led to a few problem threads already. Not a big deal if you know what you're doing but I've seen some inexperienced users make some really bad SEO choices.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska
Who is online

Users browsing this forum: edkny and 127 guests