• Priority: 0
  • Status: Waiting on customer
  • Theme: Alysum
  • Assigned To: Fred
  • Private: No
  • Open Date: 16.01.25, 15:29
  • Opened by: Nicola

Ticket #25920 - Blog's sitemap link

Hi, i noticed an error generated on the sitemap, and i think is caused from some issues in the blog menu. I try to explain:
If you go on the blog’s page and you choose an article, i have these links:
https://test.cebsas.it/it/blog/news/differenze-dei-cavi-usb-c (for the italian language)
https://test.cebsas.it/en/blog/news/usb-c-cable-differences (for the english language)

These links are correct. If you have a look in the sitemap EN version i find:

<![CDATA[ https://test.cebsas.it/it/blog/news/usb-c-cable-differences ]]>
As you can see, the prefix of the language is IT in the english version, and the other part of the link is with the friendly url in english version. In this situation is taking the prefix of IT rather than EN.

You can have a look of the sitemap EN version here, and in attachment the other example:
https://test.cebsas.it/1_en_0_sitemap.xml

I noticed that if you analyze the script of the blog’s article, inside the header tag there is the canonical tag (correct), but are missing the alternate IT version, alternate EN version and alternate X-default. Could be possible that the error is generated from this?

Attachments:

error_blog.jpg (170.4 KiB)

Comments

Fred 16 Jan 2025, 22:01

Hi, Nicola.
How do you generate those XML file?

Nicola 17 Jan 2025, 08:12

with the standard module, google sitemap

Fred 17 Jan 2025, 21:11

Why I asked, because that's a question to a tool, in this case to google sitemap module, but not to the blog module.
And the blog module shows/generates links correctly, isn't it?

Nicola 20 Jan 2025, 17:27

Yes exactly, links of the blog are correct but are not in the sitemap. I'm wondering why, because all other links are generated correctly and only blog's links are not correct. What could be the problem? Where the sitemap take the link from the script of the blog page?

Fred 20 Jan 2025, 19:28

I can't answer because it requesters sitemap module code review to understand how it works.

Nicola 22 Jan 2025, 09:07

It's very strange.
I have 3 sites with prestashop.
2 sites (ps 8.x) have your theme installed and checking I have same problem on both.
1 site (ps 1.7.8.x) with a different theme and this problem is not there.
All 3 sites have the same module for generating the sitemap and all 3 sites have the blog.
It seems like the sitemap module and the blog module are not able to communicate well and this error occurs.
Do you have a yours test site or other client's site to check this thing?

Nicola 22 Jan 2025, 10:40

I looked to modify the files to add the alternate for the two languages, as it is missing. I don't know if it is an error that can be linked to the error in the sitemap but in any case it is an error for SEO. Can you tell me where to modify the file to add the alternate for the two languages? it appears throughout the site, only in the blog it's missing.
Also browsing via ftp in the files, I noticed that in the module folders there are indications regarding the 1.6 and 1.7 versions with separate folders. Since it is all on PS 8, maybe it is a compatibility problem? maybe it is just a matter of updating the blog's module

Nicola 22 Jan 2025, 11:26

I noticed an error about the language change, there is a 301 redirect, I reported in the image the script with the wrong link when trying to change the language from IT to EN and viceversa.
Could this also be the problem or is it a different problem?
If I try the same language change on a product page instead it is correct, only when you are in the blog it happens

Attachments:

Fred 22 Jan 2025, 23:18

I found a function (hookgSitemapAppendUrls) in blog module that manipulates with links for sitemap. So the problem might be there.
Since we are not module developers we can only report this issue to the author. As I know they are preparing big update in nearest time so we could expect a fix for that as well.

Nicola 23 Jan 2025, 08:55

Ok thanks, I'm waiting for the update.
But the blog module installed with your theme is the one I find among the modules namely Blog for Prestashop by PrestaHome?
can you please tell me where I find the hookgSitemapAppendUrls function that you found? in the meantime that the update comes out I'll try to fix it

Fred 23 Jan 2025, 14:50

the file is

/modules/ph_simpleblog/ph_simpleblog.php
Nicola 07 Feb 2025, 09:35

Hi Fred, i tried to install another plugin of the blog to test, and even with that i have the same issue. I noticed the problem could be caused from the Translation flag, in attachment the error.
I tried both default and premium switch language plugin but the issue is the same. (now i have in test 2 headers, one default and the other in premium version)
This issue is only inside the blog side, in the other part of the website is ok.
Did you have any news from developers of the blog's module? Or do you have any suggestion where to check to fix it?

Attachments:

blog.jpg (182.9 KiB)
Nicola 07 Feb 2025, 10:03

Could be a problem of slug? I made a check about the wrong link and i noticed there is an automatic redirect 301. Then if you analyze:
Wrong link: https://test.cebsas.it/en/blog/news/differenze-dei-cavi-usb-c Redirect to right link: https://test.cebsas.it/en/blog/news/usb-c-cable-differences Is there any settings in your theme about multilanguage link?

Fred 07 Feb 2025, 23:43

The theme is definitely not responsible for url managing. The problem either with Blog module or with the sitemap. If that's the first case? then we have to wait for module update and hope it will be fixed there

Nicola 10 Feb 2025, 08:33

ok but i tried with another blog's module and the problem it's the same. I doubt about the problem inside the blog's module. I think it's more of a problem with the change language that is incompatible with the blog.

Nicola 10 Feb 2025, 18:58

Hi, probably i just fixed the problem about the sitemap site. The error was inside the ph_simpleblog.php, and i replaced this part of code. Now inside the sitemap is generated correctly. It remains the problem about the "link preview" on language's flag but on the sitemap is working correctly.

public function hookgSitemapAppendUrls($params)

  {
  $lang = $params['lang'];
  $idLang = (int) $lang['id_lang'];
  $idShop = (int) $lang['id_shop'];
  // Recupera le categorie con la lingua corretta
  $categories = SimpleBlogCategory::getCategories($idLang, true, true, $idShop);
  $blogCategoriesLinks = [];
  $blogPostLinks = [];
  foreach ($categories as $category) {
  // Forza l'utilizzo dello slug tradotto
  $params = [];
  if (!empty($category['link_rewrite'])) {
  $params['rewrite'] = $category['link_rewrite'];
  }
  $categoryLink = Context::getContext()->link->getModuleLink(
  'ph_simpleblog',
  'list',
  $params,
  null,
  $idLang,
  $idShop
  );
  $blogCategoriesLinks[] = [
      'type' => 'module',
      'page' => $category['name'],
      'link' => $categoryLink, // URL tradotto
      'image' => false,
      ];
  }
  // Recupera i post
  $postsFinder = new BlogPostsFinder();
  $postsFinder->setIdLang($idLang);
  $postsFinder->setIdShop($idShop);
  $posts = $postsFinder->findPosts();
  foreach ($posts as $post) {
      $postLink = Context::getContext()->link->getModuleLink(
          'ph_simpleblog',
          'single',
          [
              'rewrite' => $post['link_rewrite'],
              'sb_category' => $post['category_rewrite']
          ],
          null,
          $idLang,
          $idShop
      );
      $blogPostLinks[] = [
          'type' => 'module',
          'page' => $post['title'],
          'link' => $postLink,
          'image' => false,
      ];
  }
  return array_merge($blogCategoriesLinks, $blogPostLinks);
  }
Fred 11 Feb 2025, 14:37

I can resend your solution to the module author to verify and implement in the next update, if you want

Nicola 11 Feb 2025, 15:05

Yes sure, then in next update could be fixed

Fred 11 Feb 2025, 15:43

Okay, I’ve just sent an email to the author.