Shopware 6 - Implement a data feed for Sooqr

May 11, 2021 - 3 min read

The default search in Shopware 6 is terrible. It baffles me how the developers of e-commerce frameworks can skimp out on implementing a good-working search functionality so easily. As such, there’s a proliferation of external tools available to do search/merchandising/recommendation/personalisation in e-commerce frameworks.

Sooqr is one of them and it’s a great platform to quickly build a nice search feature with. We had to implement this in a Shopware 6 installation for a client of ours. It turns out, Sooqr doesn’t offer a Shopware 6 extension for their product but it’s relatively easy to implement it. If you know where to begin. Luckily, I did that for you.

Step 1: create a dynamic product group in the backend under Catalog > Dynamic Product Groups. Just name it ‘Sooqr’ (or whatever) and set the condition to whatever you like. If you want all of your products in Sooqr, set a condition on Price is greater than 0. Step 2: create a Product comparison Sales Channel. Click on the + besides “Sales Channels” and click on “Add Sales Channel” next to “Product comparison”. Do your settings, pick XML as the file format, enable “Export variants as discrete products” and choose the just created Dynamic Product Group. Set the status to Active and save. Step 3; click on the Template tab at the top of the page and use these values;

Header row:

<rss xmlns:sqr="http://base.sooqr.com/ns/1.0" version="2.0" encoding="utf-8">

Product row:

    <sqr:id>{{ product.id }}</sqr:id>
    <sqr:sku>{{ product.productNumber }}</sqr:sku>
    <sqr:title>{{ product.translated.name }}</sqr:title>
    <sqr:description>{{ product.translated.description }}</sqr:description>
    <sqr:brand>{{ product.manufacturer.translated.name }}</sqr:brand>
    <sqr:url>{{ seoUrl('frontend.detail.page', { productId: product.id }) }}</sqr:url>
{% if product.cover.media.url is defined %}
    <sqr:image_link>{{ product.cover.media.url }}</sqr:image_link>
{% endif %}
{% if product.active %}
{% else %}
{% endif %}
{% for i in 1..5 %}
    <sqr:category{{ i-1 }}>
{% for category in product.categories %}
{% for bc in category.getPlainBreadcrumb()|slice(i,1) %}
      <node>{{ bc }}</node>
{% endfor %}
{% endfor %}
    </sqr:category{{ i-1 }}>
{% endfor %}
    <sqr:price>{{ product.calculatedListingPrice.from.unitPrice }}</sqr:price>

Footer row:


Now click Save. Navigate back to the General tab, scroll down to “API Access”, click on “Generate new access key” and visit the Export URL you get. This will generate the XML file for you. Give the file to Sooqr and they’ll supply you with the Javascript you need to implement (through Google Tag Manager, for instance).

I tried generating the file with bin/console product-export:generate but apparently that’s by default not possible for Product Comparison Sales Channels, for some reason. I posted a workaround in the Shopware issue tracker; https://issues.shopware.com/issues/NEXT-14904

Update: I found out that the sales channel ID you pass to bin/console product-export:generate should NOT be the sales channel ID of the Product Comparison Sales Channel itself, but of the Sales Channel that you configured as the “Storefront Sales Channel” in the Product Comparison Sales Channel configuration!

Kyle Mathews

Written by Peter Jaap Blaakmeer @PeterJaap