Creation of canonical URL's since Hikashop 4.3.0

  • Posts: 20
  • Thank you received: 1
  • Hikashop Business
4 years 6 months ago #318394

-- url of the page with the problem -- : therailwayconductor.co.uk/
-- HikaShop version -- : 4.3.0
-- Joomla version -- : 3.9.18.
-- PHP version -- : 7.3.17
-- Browser(s) name and version -- : Firefox 75.0 (64-bit)
-- Error-message(debug-mod must be tuned on) -- : none

Hi Team, firstly to say a huge thank you for the awesome Hikashop, top work!
Now to my issue: previously the generation of canonical URL's via the 'use canonical URL's and generate if missing' method made working with products that existed in multiple categories easy. A quick visit to the front of the site and viewing the relevant category would set the canonical to the desired category. This worked well as categories can be used in multiple ways: unpublished and not visible to the visitor, new stock categories for badges etc. It was also easy therefore to create new categories, assign products to it, clear the canonicals via a mass action, visit the front and set the new canonicals.
Since the latest Hikashop release we have been in a world of pain!
Previously on product creation a mass action would run, setting certain defaults for products and adding a 'default' list of categories: new stock, all products etc.
Could you explain what advantages the new method of canonical creation brings and how it works.
We now have new product canonicals pointing all over the site and as we also use SH404sef with url caching turned on, it is an absolute pain to get the canonicals set how we want.
Very Best Regards
Graham Wales

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
4 years 6 months ago #318399

Hi,

We didn't change anything regarding the creation of canonical URLs in the 4.3.0, so I'm not sure what you're talking about.
The 'use canonical URL's and generate if missing' method is still there and still working fine as far as I know.

Note that if you use sh404SEF, then it introduces a complexity if you have the "force canonical URLs on listings" setting activated. If sh404SEF bases itself on its cache of non-SEFed / SEFed URLs to "decode" the SEFed URLs.
With that setting activated, HikaShop doesn't generate the URL that will be used on the listings as it directly use the canonical URL.
If you clear sh404SEF's cache of non-SEFed / SEFed URLs while you have canonical URLs in your products and that this "force canonical URLs on listings" setting is activated, then sh404SEF won't be able to get the non-SEFed URL from the URL of the product in the listing and thus it will generate a 404 error when you click on the link.
In that case, you would have to empty the canonical URL fields of your products / categories and browse your products listings again on the frontend to regenerate the canonical URLs so that sh404SEF can redo its cache of these URLs.

Please Log in or Create an account to join the conversation.

  • Posts: 20
  • Thank you received: 1
  • Hikashop Business
4 years 6 months ago #318443

4.3.0 Change log - Improvements "The system now tries to use in priority the menu item linked to the main category of the product for the generation of the SEF link to the product page in order to reduce the need of forcing canonical URLs on listings, thus, simplifying the managing of the shop."

We have changed nothing else except updating Hikashop.
Previously when a product had a blank canonical (either product just created or by clearing the canonical) it was possible to browse to the front end category and that would fill the product canonical according to the category that the product was first viewed in.
Now this does not work - try it.
Create a product with three or four categories and a blank canonical. Go to the front of the site and view the category listing page.
Now the canonical has been set to any one of the products categories, but not necessarily the category that is being viewed from the front of the site.
I am not experiencing 404 errors just the canonical being filled referencing the wrong category, over which I do not appear to have any control now, sometimes it fills with the category being viewed, other times with one of the other categories of the product with no consistancy.

Last edit: 4 years 6 months ago by speru. Reason: Removed the suggestion that Jsitemap was influencing the choice of sef url used as the product canonical. Tested with Jsitemap disabled and produced the same results.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
4 years 6 months ago #318444

Hi,

This change only improves the way the SEF URLs are generated by searching a bit more for the correct menu item to use.
It doesn't change when the canonical URL is generated.

Just to make sure, I just did a test with a few products and the canonical URL of the products were properly generated on the frontend when I displayed the listing of these products.
So please double check.

Please Log in or Create an account to join the conversation.

  • Posts: 20
  • Thank you received: 1
  • Hikashop Business
4 years 6 months ago #318496

Hi Nicolas, I have been using Hikashop for nearly 8 years and can assure you that the generation of the canonical URL used by products since 4.3.0 has changed on our system. Sure sometimes it will use the url of the category viewed, but not every time. I have done copius tests both on a live site and on my local stack.
eg. new product created: categories: scenery, all products, just arrived. Viewed category: scenery. Canonical url set: just arrived.
Can you explain further what you mean by "the correct menu item to use" and how that SEF url is generated if it is not by viewing the item for the first time in a given category?

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
4 years 6 months ago #318506

Hi,

A SEF URL is generated from an non SEF URL. As you know, the first part of a SEF URL on a Joomla website is the alias of the menu item. The SEF system knows what menu item to use as the non SEF URL contains a Itemid parameter with the id of the menu item.
If the menu item of the URL is not of the same type as the component displaying the page, it will usually result in a 404 error when trying to access that URL. When you create a HikaShop content module, you have a "menu" setting there where you can select a menu item to use to display the products/categories of the module. If the menu item selected in that setting is not of one of the menu items of HikaShop, it will generate a 404 error.
In order to avoid that, HikaShop already had a system to verify that the menu item is correct when it generates a SEF URL. And in case the menu item was wrong, it would auto correct it by choosing another one automatically.
Before this improvement, HikaShop would take the first menu item of a HikaShop menu item type it would find.
With this improvement, HikaShop tries to search for a menu item which makes sense for the URL, looking for a menu item with the correct category.
This improvement doesn't change the temporality of how and when the SEF URL used as the canonical URL will be generated.
On the frontend, when you display a products listing with that product on it, it will generate the canonical URL if it is missing by taking into account the current menu item.
Now you're talking about categories and how a category is used in the URL of a product page. But HikaShop does not include the alias of any category in product pages. So I can't say anything about your example.
If you think there really is a problem, please provide a backend access and precise instructions of what to do to reproduce the issue. Then, we can look into it.

Please Log in or Create an account to join the conversation.

  • Posts: 20
  • Thank you received: 1
  • Hikashop Business
4 years 6 months ago #318533

Thanks Nicolas, We now have a number of products ready to be published.
I was waiting until the issue of the incorrect canonical being set was resolved before publishing them.
I can provide back end access for you to publish some of these items to see how it goes.
What is the best method of providing you with the access information?

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
4 years 6 months ago #318536

Hi,

The best is that you use our contact form:
www.hikashop.com/support/contact-us.html
Make sure that you provide a link to this thread and precise instructions to reproduce the problem (what product to publish, what canonical URL you want, what do you do on the frontend after you publish the product to reproduce the problem).

Please Log in or Create an account to join the conversation.

  • Posts: 20
  • Thank you received: 1
  • Hikashop Business
4 years 6 months ago #318588

Thanks Nicolas
message sent.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
4 years 6 months ago #318666

Hi,

I checked the situation and I was able to reproduce the problem 100% of the time with the publishing of the "Hornby R6956 Tiphook KFA Container Wagon 93367 And 2 ONE Containers" product.
I've emptied again the canonical URL of that product and unpublished it after my tests.
Now to go further here as I don't have the issue on my end, I would need to add some debugging in the code generating the URL of the product on the listing to understand why it's doing this.
Could you provide a FTP access too ?

Please Log in or Create an account to join the conversation.

  • Posts: 20
  • Thank you received: 1
  • Hikashop Business
4 years 6 months ago #318667

Thanks Nicolas, yes I can provide FTP access but will need your IP address to allow connection to the server. Assuming that it is a static address could you send by reply to my email address as used in the contact message. I will provide log in details in return.
Many thanks
Graham

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
4 years 6 months ago #318703

Hi,

Thanks for the access.
So I figured out what is the problem.
When HikaShop generates the URL, it now tries to search for a menu item assigned to the main (first) category of the product so that it can use it, instead of the current menu item. That way, you don't have to display the product listing on the frontend after you enable the product as if you have a menu item for the main category of your product, you're guaranteed that it will use the menu item associated with that category when generating the URL.
However, there was a bug in the query loading the categories of the product leading to the categories not being sorted properly in some cases.
I've fixed that and added the patch on your website and on ours.
Also, I see that the menu item you want is the "wagons" one. However, the main category of your "Hornby R6956 Tiphook KFA Container Wagon 93367 And 2 ONE Containers" product was "all products", leading to the URL generated with your main menu item alias instead of the "wagons" menu item. So I've moved that category as the first one of this product and confirm that I got the desired canonical URL.
Now, taking a step back, this also means that you might not necessarily want for HikaShop to auto select the menu item. So I've also added a hidden config parameter with the manekey auto_search_menu_item_based_on_main_category which can be added to the hikashop_config table with the value 0 via PHPMyAdmin in order to deactivate the auto search of the menu item so that it works like before. I've added that hidden setting (but didn't add it to the database) on your website, and on our end.

The following user(s) said Thank You: speru

Please Log in or Create an account to join the conversation.

  • Posts: 20
  • Thank you received: 1
  • Hikashop Business
4 years 6 months ago #318720

Brilliant! Thanks Nicolas for taking the time to debug it.
And just to clarify: the first category selected in a product's Main Options is considered to be the product's main category.
(the order of the categories that a product was assigned to wasn't previously as important as it is now with auto search of the menu items when setting canonical URLs)
I will probably disable the auto search function, especially when assigning a number of products to a new category and clearing exisiting canonicals as the order of categories selected for each of those products would otherwise need looking at. The same would apply if the SEF URL table was to be purged.
Thanks again.
Graham

Please Log in or Create an account to join the conversation.

Time to create page: 0.073 seconds
Powered by Kunena Forum