Sitemap URLs with URL-Segment

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
kredohi
Posts: 5
Joined: 23 Jan 2020, 23:43

Sitemap URLs with URL-Segment

Post by kredohi » 23 Jan 2020, 23:53

Hey,
I used the sitemap scheduler task for quite a while and it worked good, but now I wanted to use some more functionality of the extension and encountered a couple of problems.

1) If I create a URL segment in the texts section of a product to generate different urls for different languages, the sitemap url become invalid because they are still based on the product label. (If I try to open those URLs they show that the article was not found, obviously because the url segment is working in the frontend, but not for sitemap url generating). Additionaly the url based on the label doesn't provide urls for multiple languages.

2) I wanted to use the category sitemap aswell as I have to setup a shop with more categories, but the generated category URL doesn't use any realURL generation, it gives long urls with lots of parameters.

Maybe you already know that and have a solution for it. I'm not a huge php developer but I could replace things in the code aswell or debug a bit if you give me a hint where to check for a change.

Looking forward to a solution :)

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Sitemap URLs with URL-Segment

Post by aimeos » 25 Jan 2020, 14:14

Seems like we have to loop over the available product names/url segments that are available for the different languages:
https://github.com/aimeos/ai-controller ... hp#L20-L27
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Sitemap URLs with URL-Segment

Post by aimeos » 28 Jan 2020, 09:08

We've extended the template for generating the sitemap to include the URL segments:
https://github.com/aimeos/ai-controller ... 5e46013cc7

Can you test it that works for you? If you copy it to your own installation, please don't forget to change the class as well (the "['text']" is important).
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

kredohi
Posts: 5
Joined: 23 Jan 2020, 23:43

Re: Sitemap URLs with URL-Segment

Post by kredohi » 28 Jan 2020, 14:44

Wow that is great.
It doesn't work for me yet, but I'm running an installation from TER not composer and realized that there are a lot of differences, e.g already the class name in Standard.php, so I will check a view things in my installation and report if it will work.
But your code looks great, thanks for doing it ;)

kredohi
Posts: 5
Joined: 23 Jan 2020, 23:43

Re: Sitemap URLs with URL-Segment

Post by kredohi » 28 Jan 2020, 21:09

I changed my code now correctly and the url generation doesn't work for all links. I guess the URL segment feature is not integrated completely yet, because I recognized another error now using them.

1.) Sitemap:
The product sitemap now has urls generated with the URL segment (after changing my code to your latest version), but not all links are valid. If I open a link with a URL segment for the default shop language everything works, but if I open a link lets say for french language, the shop details page will open with the default english language and doesn't find this article, because the slug is for the french language (the url now: mydomain.com/shop/detail/foreign_url_segment ---- a valid url with additional parameters that would work in my shop is mydomain.com/shop/detail/foreign_url_segment?ai_locale=fr&ai_currency=EUR). This changes the shops language to the one that is needed for the URL segment.

2.) The same problem comes up using the list view of the shop. If I change the language in the list view and click on the product, the product won't be found in the details view, because the details view language switches back to the default language and doesn't keep the new selected language. The url in <a href=""> is the same as the one in the sitemap, so it's the same bug in the generation of the urls with the URL segment. They don't respect the selected language in the shop.

3.) The catalog sitemap which is not that important for me generates invalid urls (and with lots of parameters) e.g. https://localhost10/shop/detail?ai%5Bf_ ... on%5D=list
This will open the correct category, but instead of showing the products of that category in a list form it says product not found. So I guess it tries to open a specific product here.

While checking those things I realized that this is defenitely kind of complicated and goes over my knowledge level. Sorry for reporting those errors, but maybe it helps to keep everything stable and working together.

Thanks for your first changes, they make everything work correctly if you either only have one language or if you define your URL segments for 'all Languages'.

Post Reply