itinance itinance - 1 month ago 27
Smarty Question

How to manage SEO-Urls in Shopware?

It seems that Shopware has some "magic behind" when generating URLs and i am looking for someone, who can explain this to me.

This is the code of standard-template to generate SEO-urls with variables which can be configured in SEO-router-settings in the backend:

{* Product name *}
{block name='frontend_listing_box_article_name'}
<a href="{$sArticle.linkDetails|rewrite:$sArticle.articleName}"
class="product--title"
title="{$sArticle.articleName|escape}">
{$sArticle.articleName|truncate:50}
</a>
{/block}


The configuration in SEO-router-settings looks like this per default:

enter image description here

Anyway, the output is little different:

http://www.DOMAIN.de/shop/CATEGORYNAME/18/PRODUCTTITLE?c=7


(All capital letters demonstrates real correct domain-, category- and product-names, that are hidden here for the sake of privacy of my client)

The issue here is the URL-Parameter "?c=7" which isn't wanted and should be omitted as defined in SEO-router-options.

First question: how to omitt this URL-parameter "c=7" at the end of URL?

When i debug this code, i run into strange things. The following code will result in two different URLs although it is the same term executed:

enter image description here

These are the issues here:


  1. The output of {$sArticle.linkDetails|rewrite:$sArticle.articleName} is different between the href-Attribute and the second output as the caption of this link.

  2. The output of {$sArticle.linkDetails|rewrite:$sArticle.articleName} within href-Attribute will add an URL-Parameter to describe the id of the category, which isn't wanted: "?c=7"



Second question:

How can the same template-code be so different? What magic is there working behind the scenes?

Answer

I'm sure you are familiar with Shopware backend. See my answers:

  1. To remove "?c=7" from detail page url:

Set 'Remove CategoryID from Url = No' at Seo/router settings. Then clear cache.

  1. I think there is multiple shops exists or you migrated to shopware from other ecommerce systems.

You can see the connection between those 2 links at "s_core_rewrite_urls" table. Just backup the table & empty it. Click Configuration > Cache/performance menu item and do Rebuild SEO URL index. More info available at https://developers.shopware.com/blog/2015/08/11/the-shopware-seo-engine/