Noodleman Posted April 3, 2017 Share Posted April 3, 2017 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. Quote Link to comment Share on other sites More sharing options...
ayz1 Posted April 3, 2017 Share Posted April 3, 2017 Does each URL have its own unique Product ID? Quote Link to comment Share on other sites More sharing options...
Noodleman Posted April 3, 2017 Author Share Posted April 3, 2017 (edited) 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 April 3, 2017 by Noodleman Quote Link to comment Share on other sites More sharing options...
Noodleman Posted April 5, 2017 Author Share Posted April 5, 2017 @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, Quote Link to comment Share on other sites More sharing options...
Al Brookbanks Posted April 12, 2017 Share Posted April 12, 2017 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? Quote Link to comment Share on other sites More sharing options...
bsmither Posted April 12, 2017 Share Posted April 12, 2017 " for example test-with-parameters.html " Please give us a much better, concrete example. Quote Link to comment Share on other sites More sharing options...
Noodleman Posted April 12, 2017 Author Share Posted April 12, 2017 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 Quote Link to comment Share on other sites More sharing options...
bsmither Posted April 13, 2017 Share Posted April 13, 2017 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. Quote Link to comment Share on other sites More sharing options...
Noodleman Posted April 13, 2017 Author Share Posted April 13, 2017 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. Quote Link to comment Share on other sites More sharing options...
Noodleman Posted June 13, 2017 Author Share Posted June 13, 2017 Following up on this thread. I finally got it all figured out. Thank you. I used the approach that Al suggested and built on it with a bunch of other functionality. Quote Link to comment Share on other sites More sharing options...
Noodleman Posted July 19, 2017 Author Share Posted July 19, 2017 Here is the end result: https://www.cubecart.com/extensions/plugins/product-filters-filter-categories-and-build-menus-dynamically-using-product-metadata Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.