In Magento 2 or Adobe Commerce, you create a CMS block with the widget code and place it on all product pages with a widget instance. A separate GARAN label per product is kept in a product attribute that you fill by CSV import.
The code for Magento / Adobe Commerce
<div data-garantielabel></div>
<script src="https://www.garantielabel.app/widget.js" async></script>Set further options such as display and language in the code builder.
Step by step in Magento / Adobe Commerce
- Create a CMS block
Under Content → Blocks, create a new block and paste the widget code. From version 2.4.3, Page Builder opens; use the “HTML Code” element there. - Create a widget
Under Content → Elements → Widgets, create a widget of the type “CMS Static Block” for your theme. - Place it
As the layout update, choose “All Product Types” and select the container “Product View Extra Hint”. It sits below the add-to-cart button. - Flush the cache
Save, flush the cache and check a product page.
A separate GARAN label per product: attribute and CSV import
The CMS block shows the same content on every product page. That is enough for the legal guarantee notice and for a GARAN label that applies to all products. If each product needs its own GARAN label, store the label’s address in a product attribute. The theme outputs the attribute on the product page once; after that, you only maintain data.
- Create the attribute
Under Stores → Attributes → Product, click “Add New Attribute” and create an attribute with the input type “Text Field”, the Attribute Codegaran_label_urland the Scope “Global”. For the nested version, optionally add a second one withgaran_label_nested_url. Leave “Visible on Catalog Pages on Storefront” at “No”, otherwise the address also appears as text in the product details. Then drag both attributes into your attribute set under Stores → Attributes → Attribute Set and save. - Create the labels
In the customer account, under “CSV upload”, upload a file with brand, model and years, plus a columnskuwith the SKU from Magento. The result file has the columnssku;brand;model;years;label_url;label_nested_url;embed_html, separated by semicolons. - Prepare the import file
In the result file, keepsku, renamelabel_urltogaran_label_urlandlabel_nested_urltogaran_label_nested_url, delete all other columns and remove rows without an address. Save the file as UTF-8 without BOM, for example with LibreOffice or a text editor. The result file has a BOM for Excel, and according to Adobe, Magento does not reliably recognise files with a BOM. Excel adds a BOM again when you save as “CSV UTF-8”. - Import
Under System → Data Transfer → Import, choose “Products” as Entity Type and “Add/Update” as Import Behavior, enter a semicolon;under “Field separator”, select the file, click “Check Data” and then “Import”. Magento matches each row to the existing product by its SKU. - Once in the theme
A developer or your agency adds the two files below to your own theme and flushes the cache. This is a one-time change. After that, each product gets its label through the attribute only, by import or by hand on the product.
The layout file app/design/frontend/<Vendor>/<theme>/Magento_Catalog/layout/catalog_product_view.xml adds a block below the add-to-cart button, in the container product.info.extrahint. If your theme already has this file, only add the referenceContainer there:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="product.info.extrahint">
<block class="Magento\Catalog\Block\Product\View" name="garan.label"
template="Magento_Catalog::product/view/garan-label.phtml" after="-"/>
</referenceContainer>
</body>
</page>The template app/design/frontend/<Vendor>/<theme>/Magento_Catalog/templates/product/view/garan-label.phtml only outputs something if an address is set on the product. data-nur="garan" shows the GARAN label alone, because the CMS block already shows the legal guarantee notice. If the nested version is set, it appears, and a click opens the full label:
<?php
/** @var \Magento\Catalog\Block\Product\View $block */
/** @var \Magento\Framework\Escaper $escaper */
$full = trim((string) $block->getProduct()->getData('garan_label_url'));
$nested = trim((string) $block->getProduct()->getData('garan_label_nested_url'));
if ($full === '') {
return;
}
?>
<div data-garantielabel data-nur="garan"
data-garan-voll="<?= $escaper->escapeUrl($full) ?>"
data-garan-klein="<?= $escaper->escapeUrl($nested) ?>"></div>
<script src="https://www.garantielabel.app/widget.js" async></script>If the CMS block itself already contains a GARAN label (data-garan-voll), remove it there, otherwise two will appear. The layout file per SKU (catalog_product_view_sku_{sku}.xml, further down) is now only worth it for a handful of products, because every file is a change to the theme.
Configurable products
On the page of a configurable product, the template outputs the attribute of the parent product. When the customer chooses an option, the page stays the same and the label does not change with it. If all variations have the same brand, model identifier and guarantee period, simply set the label on the parent product, that is in the row with its SKU. A separate label per variation needs additional JavaScript that inserts the addresses of the selected variation. It is often simpler to keep such models as separate products.
Things to know about Magento / Adobe Commerce
- With an active Content Security Policy (module Magento_Csp),
www.garantielabel.appmust be on the whitelist for scripts, images and connections. - JavaScript bundling and minification should not include the external script.
Where the notice belongs in Magento
All product pages use the layout file catalog_product_view.xml. On top come files per product type, such as catalog_product_view_type_configurable.xml, and per single product, such as catalog_product_view_sku_{sku}.xml. The column with price and buy area is the container product.info.main. It holds product.info.extrahint, which is called “Product View Extra Hint” in the widget form.
In the Admin, you create widgets under Content → Elements → Widgets. “Display On” sets the page type, “Container” the area of the page. For product pages, choose “All Product Types” or a single product type. For the notice in the footer, add a second layout update: “All Pages” with the container “Page Footer”, ideally with data-darstellung="link".
Configurable products and model identifier
A configurable product appears as one product with drop-down options. According to Adobe, each variation is a separate simple product with its own SKU. The configurable product itself is the frame; its price comes from the variations.
The Adobe documentation names no dedicated field for the model identifier. You create a product attribute for it under Stores → Attributes → Product, then add it to your attribute set under Stores → Attributes → Attribute Set. With “Visible on Catalog Pages on Storefront” set to “Yes”, it appears on the product page. Because each variation is a product of its own, it can carry its own model identifier.
The GARAN label names the brand and the model identifier, so there is one label per model identifier. The widget shows one GARAN label per placeholder and does not change with the selected option. For a label that belongs to one product only, developers use that product’s layout file (catalog_product_view_sku_{sku}.xml). If variations have different model identifiers, these models are better kept as separate products. For many products, see the attribute and CSV import method above.
Typical pitfalls in Magento
- Full page cache: Product pages are stored ready-made in the Page Cache. After changes, refresh the cache types Page Cache, Layouts and Blocks HTML output under System → Tools → Cache Management.
- Widget tied to the theme: Each widget instance belongs to one Design Theme. After a theme change, create the widget for the new theme.
- Store views: Under Storefront Properties, you choose the store views in which the widget appears. With several languages, check each store view.
- Own theme: Your own layout files belong in a theme of your own. Adobe advises against modifying the out-of-the-box themes, for compatibility and upgrades.
Further sources
- Adobe Commerce: Product layouts
- Adobe Commerce: Create a widget
- Adobe Commerce: Block positions
- Adobe Commerce: Configurable product
- Adobe Commerce: Create product attributes
- Adobe Commerce: Cache management
- Adobe Commerce: Create a storefront theme
- Magento Open Source: “Display On” options (GitHub)
Legal guarantee notice in the order confirmation
According to the Commission’s guidelines, the notice should also appear in the confirmation email. You maintain email templates under Marketing → Email Templates. The official graphic can be added as an image to the “New Order” template. A plain link is unlikely to count as a durable medium (CJEU, Case C-49/11, Content Services); the safest way is to put the notice directly in the email as an image, text or attachment. You will find the official files on our download page.
Producer guarantee? Then add the GARAN label
If the producer gives a commercial guarantee of durability of more than two years free of charge for the whole good, the GARAN label also belongs on the product page. With the GARAN label generator you create it in seconds from years, brand and model, your first three labels free and without sign-up. Below every finished label you get an embed code with permanent image URLs: you upload nothing and paste it into Magento / Adobe Commerce as shown above.
Prefer your own files? Then upload the full and the nested version to the media library of Magento / Adobe Commerce and enter the addresses in the widget code:
<div data-garantielabel
data-garan-voll="https://…/GARAN-MX-500.svg"
data-garan-klein="https://…/GARAN-MX-500-nested.svg"></div>The widget then shows the nested version below the legal guarantee notice, and one click opens the full GARAN label.
Frequently asked questions
Can I do it with layout XML?
Yes. Developers add the block via layout XML in catalog_product_view.xml.
How do many products get their own GARAN label?
Through a product attribute such as garan_label_url, which you fill from the result file of the CSV upload under System → Data Transfer → Import. The theme outputs the attribute once; after that, it is all data maintenance.
Does it work with Hyvä?
Yes. The widget does not depend on RequireJS or Knockout and also runs in Hyvä themes.
Do I have to flush the cache?
Yes, after creating the widget, otherwise the block only appears later.
Can I add a GARAN label for one product only?
Yes. For many products the easiest way is a product attribute and the CSV import, described above under the attribute and CSV import section. For a handful of products the layout file catalog_product_view_sku_{sku}.xml also works; it only applies to the product with that SKU.
Does the widget appear in all store views?
Only in those you select in the Storefront Properties of the widget instance.
What do I need to do after a theme change?
Widget instances belong to one Design Theme. Create the widget for the new theme, refresh the cache and check a product page.