Product comparison

With the sales channel product comparison you can export products to existing price portals. Furthermore you can create complete connections to new marketplaces. By using an export template that works with Twig variables, you can quickly make adjustments and create new exports.

For most portals, a link to the export file can be provided. Depending on the caching method, the file is regenerated each time it is called up and the portal always receives the most current data status. Alternatively, the file is renewed at regular intervals and the portal can fetch the file much faster.

General

General Settings

In the general settings you first enter the name for your product comparison. If you would like to use the product comparison for a large price portal, you can also select one of the available templates here. The template will then be configured correctly for the portal in question.

Storefront Sales Channel

Here you specify the sales channel (1) and storefront domain (2) to which your product comparison refers. You also specify which currency (3),  language (4) and customer group (5) should be used for this product comparison.

Product export

In the product export section you specify how the output file of the product export should look like. First you specify a Filename (1).
As encoding (2) you can select UTF-8 or ISO-8859-1. Here you should inform yourself at the corresponding price portal, what is needed here.
As file format (3) you can choose a CSV file or a XML file. Also here you should inform yourself at the price portal, what is desired here.
You also specify whether or not you want to include the product variants (4) in the export and enter a generation interval (5). Set the interval (5) for the generation using the scheduler. The product comparison file is just regenerated automatically if the interval has expired and the option Generate via scheduler (6) is activated. You execute the scheduler by executing the command bin/console scheduled-task:run in your shop main directory.
You can use a dynamic product group (7) to define which items from your shop should be included in the product export. You can find out exactly how to create them here.

API access

In the API Access section you can generate an API Access ID for this product comparison. For more information on how to use your own API accesses, please refer to our developer documentation.

In addition, the export URL for this specific product export is displayed here. This URL can be entered in the price portal.

If an error is displayed when calling up the export URL through the browser, check your dynamic product groups.
Add the conditions of the feed in the product group under "Catalogs > Dynamic product groups", e.g. "Sales price > 0" and " e.g. Price > 0".

Status

Here you can temporarily deactivate the product comparison. The call of the product comparison URL and the API will then be temporarily inaccessible. You can also activate the maintenance mode here. The call is restricted and only available for selected IP addresses that are white listed.

Delete Sales Channel

If you delete the product comparison using this button, it will be irrevocably removed. You should only do this if the sales channel is no longer needed.

Template

The template determines the structure of the product export file. The template is divided into a header line, a product line and a footer line.
If you use a template in the General tab, usually no adjustments are necessary here. The correct document templates for the respective comparison portals are already included in the templates. 
The Test template button checks whether there are any syntax errors in the template. With Generate preview you can directly view the content of the created export file.

Header row

The header row differs depending on the selected format. 
For a CSV file, the column descriptions are defined here, for example: id, manufacturer, model_no, name, category, price, etc.
In the case of an XML file, the entire file header is also located here, as well as the start tag, title, description, etc.

Product row

Here you define the template for the articles that are to be exported. The template is applied to each article using a loop. For CSV/TXT exports this results in one line per article. With an XML export, e.g. Google, each article is enclosed by a start and end tag. So it is possible to customize the exports, depending on structure and requirements. Note the more calculations are performed in the feed, the slower the generation will be!
 

The footer is only required for XML exports. This field contains the end tags that are opened in the header.

Variables

With the help of variables you can add information about the products and the product export to the template. The necessary variables for the respective export are already created in the templates. 
For your own exports you can also add your own information with variables.
Each variable starts with product or productExport and can be extended with a dot, for example product.productNumber for the product number.
The variables can also be multi-level. For example, the variable for the product name is product.translated.name.
If you write a dot after a level, all available sublevels are displayed.

List of available Variables

Configuration variablesDescription
productExport.salesChannelDomain.urlURL of the Saleschannel
context.salesChannel.nameName of the Saleschannel 
Export settingsDescription
productExport.fileNameexport filename
productExport.accessKeyAPI - Access key
productExport.encodingEncoding standard
productExport.fileFormatFile format
productExport.includeVariantsSpecifies whether variants are also exported
productExport.salesChannel. ...Data on the specified SalesChannel
productExport.salesChannelDomain. ...Data on the specified SalesChannel Domain
Product settings (Only in the product row)Description
product.activeProduct is activated
product.productnumberProduct number
product.translated.nameProduct name
seoUrl('frontend.detail.page', {'productId': product.id}) Product-URL
product.translated.descriptionDescription
product.deliveryTimeDelivery time
product.restockTimeTime needed to restock the product in days
product.minPurchaseMinimum purchase
product.maxPurchaseMaximum purchase
product.availableStockAvailable stock
product.manufacturerNumberManufacturer number
product.eanEAN
product.manufacturer.translated.nameManufacturer name
product.cover.media.urlProduct picture URL
product.calculatedPrice.listPrice.priceList price
product.categories.first.getBreadCrumbOutput of the categories
product.stockQuantity in stock
product.availableProduct is available
product.deliveryTimeProduct delivery time
product.deliveryTimeIDProduct delivery time ID
product.isCloseoutProduct is marked for clearance sale
product.purchaseStepsThe steps in which the product can be bought
product.referenceUnitProduct reference unit
product.shippingFreeThe product has free shipping
product.markAsTopsellerProduct is an top seller
product.weightWeight of the product
product.widthWidth of the product
product.heightHeight of the product
product.lengthLength of the product
product.releaseDateProduct release date
product.keywordsProduct keywords
product.descriptionProduct description
product.metaDescriptionProduct meta description
product.metaTitleProduct mate title
product.packUnitproduct pack unit
product.packUnitPluralProduct pack unit plural

  

Custom fields

You also have the option of including custom fields in the template.
The technical name of the custom field is required for this. You can find this in the settings of the additional field.
The general structure for an custom field variable is as follows:

For a product custom field:

{{ product.translated.customFields.technical_name_of_the_custom_field }}

e.g.:

{{ product.translated.customFields.further_information }}

It is also possible to query custom fields of the product manufacturer.

{{ product.manufacturer.translated.customFields.technical_name_of_the_custom_field }}

e.g.:

{{ product.manufacturer.translated.customFields.manufacturer_information }}

It can be useful to include the query of the additional fields in an if-query, so that the output only occurs if the field is also filled.
This is possible, for example, as follows:

{% if product.translated.customFields.technical_name_of_the_custom_field is defined %}
{{ product.translated.customFields.technical_name_of_the_custom_field }}
{% endif %}

Properties

By adapting the template, properties can also be output and transferred. The product properties are located in the array product.properties. This can show you the properties.

{% for properties in product.properties %}
{{ properties.name }}
{% endfor %}

If you want to output a specific property group, you can limit and query it with an additional if query.

For example:

{% for properties in product.properties %}
{% if properties.group.name == "size" %}
    {{ properties.name }}
{% endif %}
{% endfor %}

Images

By using a condition that ends with an endif tag, you can display multiple image urls of a product. In the following query, five other image urls are output in addition to the cover image, if any are available. You can change the number of Urls to be output as you wish.

{%- if product.media|length > 1 -%}
    "{%- for mediaAssociation in product.media|slice(0, 5) -%}
        {{ mediaAssociation.media.url }}
        {%- if not loop.last -%},{%- endif -%}
    {%- endfor -%}"
{%- endif -%}{#- -#}

Troubleshooting

Errors may occur during the product comparison, these are explained here and how to solve them.

Missing Content

By default, some content such as product images are expected. For example, if you have selected Google Shopping (XML) as the template, the export may be canceled if the dynamic product group for the feed contains one or more items that do not have a product image. In such a case, you should make sure to assign a product image to all products. 
Alternatively, you can edit the product line in the Template tab.
The product image URL is displayed using this entry:

<g:image_link>{{ product.cover.media.url }}</g:image_link>

This should be completely replaced by the following entry:

<g:image_link>

{% if product.cover.media.url is defined and product.cover.media.url is not null %}

{{ product.cover.media.url }}

{% endif %}

</g:image_link>

Thus, the first step in a product comparison is to check whether a product image is available. Only if one is available will it be included in the product comparison. 
This example can also be applied to other variables. 

Product is not assigned to a valid category

If there are items in the selected Dynamic Product Group that are not assigned to a valid and available category, the following message may occur:

{"errors":[{"status":"400","code":"FRAMEWORK__STRING_TEMPLATE_RENDERING_FAILED",
"title":"Bad Request","detail":"Failed rendering string template using Twig:
Failed rendering string template using Twig: Impossible to access an attribute (\u0022getBreadCrumb\u0022)
on a null variable in \u0022420463b818562f32a1fd3ff62050d151\u0022 at line 6.",
"meta":{"parameters":

{"message":"Failed rendering string template using Twig: Impossible to access an attribute (\u0022getBreadCrumb\u0022) on a null variable in \u0022420463b818562f32a1fd3ff62050d151\u0022 at line 6."}

}}]}

By adjusting the template, you can check in advance whether a category is stored. So this message is bypassed.
To do this, you can edit the product line in the Template tab.
The category is displayed using this entry:

<g:product_type>{{ product.categories.first.getBreadCrumb|slice(1)|join(' > ')|raw|escape }}</g:product_type>

To check the category before comparing products, replace this entry with the following:

<g:product_type>

{% if product.categories.first.getBreadCrumb is defined and product.categories.first.getBreadCrumb is not null %}

{{ product.categories.first.getBreadCrumb|slice(1)|join(' > ')|raw|escape }}

{% endif %}

</g:product_type>

Thus, when comparing products, the system first checks whether a valid category exists. Only if a category exists is it included in the product comparison.

Remove whitespaces

 

You can use a whitespace to remove unnecessary spaces or "whitespaces" on the left and right. To do this, you need to add a - at the beginning and end, as shown below.
Example with spaces:

{% for properties in product.properties %}
    {% if properties.group.name == "brandname" %}
        {{ properties.name }}
    {% endif %}
{% endfor %}

Example without spaces:

{%- for properties in product.properties -%}
    {%- if properties.group.name == "brandname" -%}
        {{- properties.name -}}
    {%- endif -%}
{%- endfor -%}

Helpful code snippets

The Shopware templates for the product comparisons and the social shopping sales channels are delivered in a standard configuration. For some products or providers, additions are necessary. For frequently requested elements, we have collected the corresponding code snippets here.

Was this article helpful?