infonyte / shopware-search
Infonyte AI semantic search, recommendations, remarketing, support
Package info
github.com/infonyte/shopware-plugin
Type:shopware-platform-plugin
pkg:composer/infonyte/shopware-search
Requires
- php: >=8.2
- shopware/core: ~6.6.0 || ~6.7.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
AI semantic search, search suggestions, cross-selling recommendations, topsellers and tracking for Shopware 6.
Requirements
- Shopware 6.6 or 6.7
- PHP 8.2 or newer
- An Infonyte instance and the token of the integration of your shop
Installation
Upload the plugin zip in the administration (Extensions → My extensions → Upload extension), then install and
activate it. Alternatively extract the zip into custom/plugins/ of your shop and run:
bin/console plugin:refresh bin/console plugin:install --activate Infonyte bin/console cache:clear
Update: replace the plugin files (or upload the new zip), then run bin/console plugin:update Infonyte and
bin/console cache:clear. The settings are kept.
Configuration
Extensions → My extensions → Infonyte → Configure, grouped by topic. All functions are switched off after the installation: enter the connection data and switch on the functions you want to use.
Connection
| Setting | Description |
|---|---|
| Environment | Production, testing or development |
| Instance Name | Name of your Infonyte instance ({name}.eu1.infonyte.io) |
| Token | Token of the integration of your shop, shown hidden |
| API Timeout (Seconds) | Timeout of a request to the search service (default 2), for the whole request; on a timeout the shop uses its own search |
Search
| Setting | Description |
|---|---|
| Enable Search | Search page and search suggestions by Infonyte (default off) |
| Suggest Limit | Number of products in the search suggestions, 1–20, default 10 |
| Enable Category Pages | Product listing of the category pages by Infonyte (default off), see Category pages |
Recommendations
| Setting | Description |
|---|---|
| Enable Cross-Sellings | Recommendations on the product page (default off) |
| Cross-Selling Kinds | Kinds of recommendations on the product page: similar products, accessories, upsell (default similar products), see Cross-sellings |
| Cross-Selling in the Cart | Kind of the recommendations for the products of the cart, for the theme: off (default), similar products, accessories or upsell, see Recommendations for themes |
| Cross-Selling Limit | Number of products per cross-selling, 1–20, default 10; also in the cart, of the topsellers and of the Store API routes of the recommendations without limit |
| Topsellers on Category Pages | Topsellers of the category for the theme (default off), see Recommendations for themes |
Tracking and Privacy
| Setting | Description |
|---|---|
| Enable Tracking | Carts, checkouts, orders and logins (default off), see Tracking |
| Send Customer Data | Data of logged-in customers with search, suggestions, cross-sellings and tracking (default off), see Tracking |
The token is stored like all plugin settings in the shop's system configuration (not encrypted); administration users with access to the plugin settings can display it.
The settings apply to all sales channels. Without instance name or with an unknown environment the plugin makes no requests, the shop uses its own search and an error is logged.
Search and search suggestions
The plugin answers the product search and the search suggestions of the shop with the Infonyte search. It replaces only the finding of the products: pages, listing, sorting, paging and the events of Shopware stay as they are, so themes and other plugins work as with the Shopware search.
Where the Infonyte search is used
- Storefront: search page with its filter panel, reloading of the listing when paging, sorting or filtering, suggestions in the search field
- Store API:
/store-api/searchand/store-api/search-suggest, e.g. for headless frontends and apps
Where the Shopware search is used
- If the search service does not answer in time (see Timeout) or returns an error
- If the first page has no hits and no filter is selected
- Without a search term
- With active filters the search service does not support: rating, free shipping and filters added by other plugins
- If Search is switched off in the plugin configuration
The Shopware search is the search the shop has set up: by default Shopware's own database search, or Elasticsearch/OpenSearch if the shop uses it.
Not affected: the product search of the administration and the Admin API. Category pages use Infonyte only with Enable Category Pages, see Category pages.
Sorting: Relevance, name, price and topseller are sorted by the Infonyte search. A sorting the shop does not know falls back to the default sorting of the shop, like in Shopware. Other sortings of the shop (e.g. custom sortings) are sorted by relevance.
Page size: The number of products per page comes from the shop (Products per page, at most 100).
Number of hits and paging: The page shows the total number of hits. The Infonyte search returns at most 100 pages: later pages (with 24 products per page after 2400 products) show no products.
Filters: Manufacturer, properties and price are filtered by the Infonyte search, which also returns the options of the filter panel. Shopware builds the filter panel as usual from them (names, order and display of the property groups and options from the shop, only filterable property groups).
- Within a filter the selected options are combined with OR, between the filters with AND, like in Shopware.
- With selected filters the panel shows the options that still have hits with the selection of the other filters; selected options always stay in the panel. Without selection it shows all options of the search.
- A selection without hits keeps the search page with its filter panel, so the selection can be removed.
- Rating and free shipping are not shown in the filter panel; if one of them is active (e.g. by a link), the shop uses its own search.
- Disable filter options without results (Settings → Shop → Products) works: the filter panel asks the Infonyte search for the options. These requests only count the hits, they are not stored as searches of the visitor.
- Price: the price filter and the price range of the panel use the gross prices of the products in the currency of the visitor as synced to Infonyte. Net prices (customer groups with net display) and currencies without own prices of the products are not considered, there the price filter can differ from the prices shown.
Variants: The products are shown in the order of the Infonyte search. If a product is set to show its main variant or the main product in listings (Product → Variants → Storefront presentation), Shopware shows that one instead of the found variant, at the position of the found variant.
Category pages
With Enable Category Pages, the products of the category pages are listed by Infonyte, like the search page without search term: the products of the category and of its subcategories, like Shopware. Pages, sorting, paging, filter panel and events stay Shopware's, as with the search.
Where Infonyte is used: category pages with a product listing (also in shopping experiences), the reloading
of the listing when paging, sorting or filtering, and the Store API route /store-api/product-listing/{categoryId}.
Where the Shopware listing is used
- If the search service does not answer in time or returns an error
- If the first page has no products and no filter is selected
- For categories whose products are assigned by a dynamic product group: Infonyte only knows the categories assigned to the products
- With active filters the search service does not support: rating, free shipping and filters added by other plugins
- If Enable Category Pages is switched off
Sorting: Topseller, name and price are sorted by Infonyte; topseller are the sales of the days set in Infonyte. Other sortings of the shop (e.g. custom sortings) are sorted by topseller.
Filters work like on the search page, see Search and search suggestions.
Large categories: Infonyte lists up to a maximum number of products per request (set in Infonyte, 5000 by default). In larger categories the sorting by price sorts the topsellers within this number, and with filters the number of products and the counts of the filter panel refer to it.
HTTP cache: category pages are cached by Shopware as before, the order of the products with them; it is renewed when the page cache is renewed (e.g. when products or the category change).
Cross-sellings
The product page gets the recommendations of Infonyte as first cross-sellings, before the cross-sellings
maintained in the shop. They are also returned by the Store API (/store-api/product/{productId}/cross-selling).
Each kind selected in Cross-Selling Kinds is a cross-selling of its own, in this order:
| Kind | Title | Recommends |
|---|---|---|
| Similar products | Recommendations / Empfehlungen | alternatives to the product |
| Accessories | Accessories / Zubehör | accessories, consumables and spare parts, those of the product's brand first |
| Upsell | Premium alternatives / Höherwertige Alternativen | similar products of the same kind, more expensive within the price range set in Infonyte, compared in the currency of the visitor |
- Products are loaded like a maintained product list: visible in the sales channel, closeout products without stock hidden according to the shop setting.
- Without recommendations (e.g. on errors or timeouts) the cross-selling is not shown, the others stay.
- One request to the search service per kind, product and page, also if the page contains several cross-selling elements. The requests of the kinds are made one after the other: with three kinds, an unavailable search service can delay the product page by up to three times the API Timeout.
Recommendations outside the product page: the cross-selling of the products in the cart and the topsellers of a category or of the shop.
- For themes: with Cross-Selling in the Cart and Topsellers on Category Pages the plugin adds them to the offcanvas cart and the cart page, or to category pages and the home page. The plugin brings no templates, the theme has to render them; without a theme that does, the settings should stay off. See Recommendations for themes.
- For headless frontends and apps: the Store API routes
/store-api/infonyte/cross-sellingand/store-api/infonyte/recommend, see Store API routes of the recommendations.
Headless frontends
Headless frontends and apps use the Store API of Shopware; the plugin works there as well. The client has to send the
same sw-context-token with every call: the session of the search service is kept at this token (see Tracking).
| Function | Store API route |
|---|---|
| Search and search suggestions | /store-api/search, /store-api/search-suggest |
| Category pages (with Enable Category Pages) | /store-api/product-listing/{categoryId} |
| Cross-sellings of the product page | /store-api/product/{productId}/cross-selling |
| Cross-selling of several products or the cart, topsellers | /store-api/infonyte/cross-selling, /store-api/infonyte/recommend, see Store API routes of the recommendations |
- The settings Cross-Selling in the Cart and Topsellers on Category Pages only apply to storefront pages, headless frontends use the routes of the recommendations instead.
- Tracking: carts, orders and logins are tracked like in the storefront; the checkout is tracked by the confirm page of the storefront only.
Tracking
With Enable Tracking, carts, checkouts, orders and logins are sent to Infonyte. Errors and timeouts are only logged and never affect the customer.
| Event | Sent |
|---|---|
| Product added to the cart, quantity changed, product removed | the whole cart with all products, total and taxes; an emptied cart with an empty product list |
| Checkout confirm page | the cart as checkout, with shipping and payment method |
| Order placed | order number, products, total, taxes, shipping and payment method, customer data |
| Customer login | customer data, only with Send Customer Data |
Products are sent with id, name, quantity, row total incl. tax and taxes; discounts and vouchers are part of the total only.
Session: The search service returns a session id, which the plugin keeps at the context of the visitor (the
context token of Shopware, in the storefront as well as in headless frontends) and sends with every following
request, so searches, clicks, carts and orders of a visitor are linked. On logout the session id is discarded; on
login it is kept, so searches made as guest stay linked to the order. The session id lives as long as the context of
the visitor (by default one day since it was last changed, shopware.api.store.context_lifetime); after 30 minutes
without requests the search service continues the visit in a new session linked to the previous one.
Customer data (logged-in customers, with search, suggestions, cross-sellings and tracking, only with Send Customer Data): customer id and number, e-mail, first and last name, title, gender, year of birth, company, account type, country of the billing address and the language of the sales channel. Values the shop does not have are sent empty. Without the setting, the requests of logged-in customers are sent like those of guests.
Request data: IP address and user agent of the visitor (the user agent is used to detect bots), and the versions of the plugin and of Shopware.
Privacy: with Send Customer Data, customer data is transferred to an external service. A legal basis (privacy policy, data processing agreement) is required.
Logging
The plugin logs to the Shopware log (var/log/). Errors of the requests (e.g. timeouts, rejected requests with the
reason) are logged as errors; requests and responses as debug entries, which Shopware writes only with debug
logging, e.g. in the development environment.
For developers: events, themes and other plugins
The plugin dispatches no events of its own and brings no templates, JavaScript or styles. It decorates the Store API routes of the search, the suggestions and the cross-sellings and dispatches the Shopware events there, so themes and other plugins keep working with the Shopware events and templates. Recommendations outside the product page are provided by Store API routes of the plugin, see below.
Events of the search, the suggestions and the category pages
The Infonyte search sits inside Shopware's handling of the search, suggest and listing routes: Shopware prepares the criteria and dispatches its events, Infonyte finds the products, Shopware loads them by id and processes the result.
| Event | With Infonyte results |
|---|---|
ProductSearchCriteriaEvent, ProductSuggestCriteriaEvent, ProductListingCriteriaEvent |
dispatched before the search; associations, includes, states, limit and sorting of the criteria are applied, see below for filters |
ProductSearchResultEvent, ProductSuggestResultEvent, ProductListingResultEvent |
dispatched with the products of Infonyte; listeners can change the result as usual |
ProductListingCollectFilterEvent |
dispatched; filters added by plugins appear in the filter panel, an active one switches to the Shopware search |
ProductListingPreviewCriteriaEvent, ProductListingResolvePreviewEvent |
dispatched while loading the products (main variant / parent product in listings) |
Entity events of the products (e.g. sales_channel.product.loaded) |
dispatched |
Page events (SearchPageLoadedEvent, SuggestPageLoadedEvent, NavigationPageLoadedEvent) and the hooks of app scripts |
dispatched, the pages are Shopware's |
Extension points product-search-route.load, product-suggest-route.load, product-listing-route.load, product.listing.criteria |
only when Shopware answers (fallback, see Search and search suggestions and Category pages) |
Filters and queries of the criteria: Infonyte applies the selection of the filter panel (manufacturer, properties, price) and loads the found products by their ids, visible in the search of the sales channel (category pages: visible in the sales channel). Filters and queries that listeners of the criteria events add to the criteria are not applied to the Infonyte results; post filters that do not belong to the filter panel switch to the Shopware search. Products that should never be found must be excluded from the data synced to Infonyte or hidden by their visibility.
The result does not contain a marker whether it comes from Infonyte or from the Shopware search.
Events of the cross-selling
The recommendations are added to the cross-sellings returned by Shopware, as product list cross-sellings with fixed
ids, from position -99999 on (first). They are not stored in the database.
| Kind | Id | Title snippet |
|---|---|---|
| Similar products | 01a2222fac28724db08ca853983d38fe |
infonyte.crossSelling.title |
| Accessories | 01a2222fac5f738e93e17eb5ea5d10ae |
infonyte.crossSelling.complementaryTitle |
| Upsell | 01a2222fac9d72e495443efc06edc012 |
infonyte.crossSelling.upsellTitle |
| Event | For the recommendations |
|---|---|
ProductCrossSellingIdsCriteriaEvent |
dispatched per recommendation with it as cross-selling and the criteria with the recommended product ids; filters, associations and changed ids of listeners are applied |
ProductCrossSellingsLoadedEvent |
dispatched separately with the recommendations as elements, in addition to Shopware's event for the maintained cross-sellings |
ProductCrossSellingCriteriaLoadEvent, ProductCrossSellingStreamCriteriaEvent |
not dispatched for the recommendations (maintained cross-sellings only) |
Listeners that handle only the recommendations or only the maintained cross-sellings can tell them apart by the ids.
Store API routes of the recommendations
Two routes of the plugin return recommendations outside the product page, e.g. for headless frontends and apps, or
for plugins and themes that call the route services in PHP (AbstractCrossSellingRoute, AbstractRecommendRoute in
Infonyte\Core\Content\Product\SalesChannel\Recommendation). Both take GET or POST, the parameters below and
the criteria parameters of Shopware (associations, includes, filter, limit), and return a product list like
/store-api/product, in the order of the recommendation.
/store-api/infonyte/cross-selling: cross-selling of several products
| Parameter | Description |
|---|---|
kind |
related (default), complementary or upsell, see Cross-sellings |
productIds |
1–20 product ids; without, the products of the cart of the context token (the first 20) |
A product recommended for several of the products comes first, the products themselves are not recommended. Without products, on errors or timeouts the list is empty.
/store-api/infonyte/recommend: recommendations without a product
| Parameter | Description |
|---|---|
kind |
topseller (default): the best selling products of the last days |
categoryId |
the topsellers of this category; without, or with the main navigation category of the sales channel, those of the whole shop |
On errors or timeouts the route returns the topsellers of Shopware instead: the products of the category sorted by sales, like the sorting Topseller of a listing.
curl -X POST https://shop.example/store-api/infonyte/cross-selling \ -H 'sw-access-key: <access key of the sales channel>' \ -H 'sw-context-token: <context token>' \ -H 'Content-Type: application/json' \ -d '{"kind": "complementary", "limit": 4, "includes": {"product": ["id", "translated", "calculatedPrice", "cover"]}}'
- Number of products: the
limitof the request, at most 20; without it Cross-Selling Limit. The search service may return fewer products. - Products are loaded like the cross-sellings of the product page: visible in the sales channel, closeout products
without stock hidden according to the shop setting. Filters of the request are applied to the recommended products;
sorting, paging and
termare not, the order and the number come from the recommendation. - Errors: an unknown
kind, invalid ids or more than 20productIdsare rejected with HTTP 400. - Cache: the routes are not in the HTTP cache, the visitor's session and the customer are part of the request to the search service. One request to the search service per call.
- Session: the search service session of the visitor is kept at the context token (see Tracking); headless
frontends keep their session by sending the same
sw-context-tokenwith every call. - Decorating: the routes follow Shopware's pattern, a plugin can decorate
AbstractCrossSellingRouteorAbstractRecommendRouteto change the products.
Recommendations for themes (page extensions)
With the settings Cross-Selling in the Cart and Topsellers on Category Pages, the plugin adds recommendations to storefront pages. It only provides the data, the theme decides whether and how to show them (e.g. with Shopware's product box or slider). Both settings are off by default: when switched on, every page of the kind makes a request to the search service, also if the theme does not render the data.
| Extension | Pages | Content |
|---|---|---|
page.extensions.infonyteCrossSelling |
offcanvas cart, cart page | cross-selling of the products of the cart (the first 20) of the kind of the setting |
page.extensions.infonyteTopseller |
category pages, home page | topsellers of the category, on the home page those of the shop |
- The content is the product list of the Store API routes above (
elements,total), in the order of the recommendation, with Cross-Selling Limit products at most. - Without products in the cart there is no request and no extension. Without recommendations (or on errors) the cross-selling is empty; the topsellers fall back to the topsellers of Shopware (sorted by sales).
- The offcanvas cart is reloaded by Shopware on every change of the cart, the cross-selling with it.
- HTTP cache: category and home pages are cached by Shopware, the topsellers with them: they are the same for all visitors and are renewed when the page cache is renewed. Shopware does not cache pages for logged-in customers and visitors with a filled cart; for them the topsellers are requested on every page view. Cart pages are never cached.
- Only on the full page: a listing reloaded by filtering or paging does not get the topsellers.
Example: the cross-selling below the products of the offcanvas cart
{% sw_extends '@Storefront/storefront/component/checkout/offcanvas-cart.html.twig' %}
{% block component_offcanvas_cart_items %}
{{ parent() }}
{% set recommendations = page.extensions.infonyteCrossSelling %}
{% if recommendations and recommendations.elements|length %}
<div class="row">
{% for product in recommendations.elements %}
<div class="col-6">
{% sw_include '@Storefront/storefront/component/product/card/box.html.twig' with { product: product } %}
</div>
{% endfor %}
</div>
{% endif %}
{% endblock %}
The topsellers work the same way, e.g. in the block page_content of page/content/index.html.twig with
page.extensions.infonyteTopseller.
Themes
-
Search page, suggestions and cross-sellings are rendered by the templates of Shopware or of the theme; template changes of the theme apply to the Infonyte results as well.
-
The titles of the recommendations are snippets (see the table above), they can be changed in Settings → Shop → Snippets.
-
Templates can recognize a recommendation by its id, e.g. in the loop over the cross-selling elements of
element/cms-element-cross-selling.html.twig:{% if item.crossSelling.id == '01a2222fac5f738e93e17eb5ea5d10ae' %} {# Infonyte accessories #} {% endif %}In the standard template the tab and its pane get the ids
cross-selling-tab-<id>andcross-selling-tab-<id>-pane, which can be used in styles.
Other plugins
- Decorating the routes: Infonyte decorates
ProductSearchRoute,ProductSuggestRoute,ProductListingRouteandProductCrossSellingRoutewith the default priority (0), inside Shopware's decorators of the search, the suggestions and the listing (priority -2000). A decorator of another plugin with a priority between -2000 and 0 receives the Infonyte results; with a priority above 0 it sits between Infonyte and the Shopware search and only runs when the Shopware search answers. With the same priority the order depends on the order the plugins are loaded. - Other search plugins: plugins that replace the product search, the suggestions or the product listing as well should not be active together with Enable Search or Enable Category Pages.
- Filters of other plugins appear in the filter panel; while one of them is active the Shopware search answers.
- Tracking listens to Shopware's events:
AfterLineItemAddedEvent,AfterLineItemQuantityChangedEvent,AfterLineItemRemovedEvent,CheckoutConfirmPageLoadedEvent,CheckoutOrderPlacedEvent,CustomerLoginEventandCustomerLogoutEvent. Cart changes of plugins that do not dispatch the line item events are sent with the next tracked event. - The services of the plugin (namespace
Infonyte\) are internal and may change with any version; use the Shopware routes and events above and the Store API routes of the recommendations.