Jump to content

Dymanic, custom SEO URL - what's the best method to use?


Noodleman

Recommended Posts

My turn to ask for advice. I've several in work modules which provide new URL's to the store front, the problem is I am struggeling to figure out how I should correctly be managing the SEO URL's through a module using hooks.

Here is a made up example of the problem and what I need to solve.

Normally cubecart uses categories as buckets for products. I've thrown this concept out of the window recently and started to use filters against a single pile of products. IE, here's 1000 products in a pile with detailed meta data. you can use dynamically built filters based on meta data to only show you the products you are interested in. The results of those applied filters is your list of products in a category view.

every unique combination of filters has it's own URL which is using URL parameters. These are 100% dynamically built. For example:
/products.html?filter_conditions[Product][]=172&filter_conditions[COLOUR][]=109

products.html is the actual cubecart category within which all of my products live, the additional parameters are filter conditions based on meta data. What I would like is dynamically built SEO URL's which include the parameters. so the URL above would become (for example) /noodles-red-shoes.html.

So, I guess my question is, how can I get my dynamically created custom SEO URLs to map to the URL I want to use including parameters, dynamically? (There are over 50,000 custom URL's in my dev store using this at the moment, so manually mapping isn't an option).

I tried playing aroud with custom URLs but I wasn't able to figure it out.

 

 


 

 

 

Link to comment
Share on other sites

The product SEO urls themselves are the same as normal. It's category views that I am interested in.

for examle products.html?a=1 could return 20 products, but products.html?a=2 could return 10 totally different products

there's typically a 1-1 relationship between an SEO URL and ab object (Product/category/document), what I need is a 1-1 relationship between the SEO URL and the category + parameters, which has to be dynamically mapped. the SEO URL's themselves are dynamiclly generated.

I've found no way to make this work yet.

Edited by Noodleman
Link to comment
Share on other sites

@Al Brookbanks, any thoughts on this topic?

If I had a category which had an SEO URL of test.html (cat_id 1), and I wanted to add some additional URL parameters, &a=1&b=2, making the URL test.html?a=1&b=2

How can I build a new SEO URl which contains those paramarters, for example test-with-parameters.html using hooks?

Many thanks,

 

Link to comment
Share on other sites

Hmmm....

Maybe the SEO database table can have an extra text column added to hold these parameters.

e.g.

id   path        typeitem_id   custom    params
----------------------------------------------------------------
1    test        cat           0         {"a":1,"b":2}   

Then replace or merge the GET variables with the value from the params column?

Link to comment
Share on other sites

Sure, let me walk through a more specific example. I think I am being as clear as mud :)

On my site I have a URL to a category:
https://www.noodleman.co.uk/order-fulfilment.html

The SEO URL being order-fulfilment.html.

When you open this URL, CubeCart looks up order-fulfilment.html from the CubeCart_seo_url database table to get the category ID.  In reality the URL contains parameters. Using a dump of $_GET those would be

array(3) {
  ["_a"]=>
  string(8) "category"
  ["cat_id"]=>
  string(3) "51"
}

so, unmasked it's https://www.noodleman.co.uk/index.php?_a=category&cat_id=51

If you go to the URL: https://www.noodleman.co.uk/index.php?_a=category&cat_id=51 CubeCart looks up the SEO URL, then re-writes the URL back to order-fulfilment.html.

 

I need to do something similar, making up a random example URL with additional parameters:
https://www.noodleman.co.uk/index.php?_a=category&cat_id=51&filter_conditions=abc&colour=blue

If that URL is accessed, I would want to re-write the URL to something more SEO frienly dynamically. in this case something like https://www.noodleman.co.uk/blue-order-fulfilment.html

Note, it's still the same category ID, I just need custom SEO URL's based on additional URL parameters for that category. Alternatively, if you were to go to the URL https://www.noodleman.co.uk/blue-order-fulfilment.html I would need it to have those additional parameters in the URL https://www.noodleman.co.uk/index.php?_a=category&cat_id=51&filter_conditions=abc&colour=blue

 

 

 

 

Link to comment
Share on other sites

I am seeing a bit of a disconnect:

At one point, we have filter_conditions => abc and colour => blue, but later all we have is abc and blue.

What is your solution to making sure that abc gets re-associated with filter_conditions and blue gets re-associated with colour?

One solution is discreetness: all possible values for the filter_conditions key will never appear as a value for any other key. And all possible values for the colour key will never appear as a value for any other key.

Next, we need to choose a delimiter for these values. I have seen the following syntax elsewhere:

www.example.com/abc,blue,order-fulfillment.html
www.example.com/order-fulfillment,abc,blue.html

Commas are legal characters in a URL.

So, the htaccess rewrite rule will give to CubeCart: seo_path=order-fullfillment,abc,blue

Then, we split on commas and merge them into the $_GET array.

Getting CubeCart to create these URLs shouldn't be too hard.

Let me think about this.

Link to comment
Share on other sites

Morning Brian,

Thanks for your time and thoughts. :)

Q: What is your solution to making sure that abc gets re-associated with filter_conditions and blue gets re-associated with colour?

A: I've already built a dynamic filter which uses logic to translate the URL parameters into filter conditions. It's complex but working well.The parameters themselves contain filter names & conditions which can be re-matched against the inventory and meta data. It's a module I want to release, but need to fix some other things with it first, like this SEO URL topic. The ability to understand the URL with parameterts and load a filtered caregory / drive menu etc already exists.

To ensure unique combinations of URL parameters regardless of the order they appear in the URL I simply grab each parameter into an array (well, it's already one in $_GET). order the array keys by a-z, 0-9, serialize then MD5 hash. The hash can then be used to match against DB records to lookup the SEO URL which was auto generated. I also store the serialized url paramrters so I can rebuild the URL.

Comment: Next, we need to choose a delimiter for these values.

A:  I don't think a delimiter is required due to the way I can store/lookup SEO url's based on the MD5 hash process i've mentioned above. md5 When trying to figure out if the URL is a dynamic filter or standard CC URL I am considering a check. validate if the SEO URL already exists in the CubeCart_seo_url table, if it does then it's a standard CC SEO URL. If it doesn't, assume it's a dynamic filter URL and apply the custom process to translate it to filter conditions.

 

Link to comment
Share on other sites

  • 2 months later...
  • 1 month later...

Join the conversation

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

Guest
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...