Field catalogs
On this page

Field catalogs

This page is for the developer who adds a platform to the feed's Type list, or corrects what the module knows about one. A field catalog describes a platform's fields: which ones the catalog marks as required, which lengths and values it checks, and where each field's value usually comes from. A mapping may still hold fields the catalog does not name.

The module reads every catalog from the etc/feed_catalog.xml files of the enabled modules. Each catalog becomes:

  • a choice in the feed form's Type list, and in the feed grid's Type column;
  • an entry under Field catalogs in the mapping's Copy from, which fills the mapping from the catalog's defaults;
  • the rules a run checks the rows against. A row that breaks one is a warning in Details and Preview, never a reason to leave the product out. A mapping row marked Required can leave a row out, as can a dictionary or a row transformer. See Row transformers.

The module ships 18 catalogs: generic, google_shopping, meta_catalog, tiktok_catalog, pinterest_catalog, snapchat_catalog, microsoft_shopping, kaufland_product, kaufland_offer, allegro, idealo, billiger, pricerunner, fruugo, beslist, heureka, zbozi and glami, in vendor/arlanix/module-product-feed/etc/feed_catalog.xml.

Add a feed type

To add a type, create etc/feed_catalog.xml in your module:

<?xml version="1.0"?>
<catalogs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="urn:magento:module:Arlanix_ProductFeed:etc/feed_catalog.xsd">
    <catalog type="example_shopping" label="Example Shopping">
        <field name="sku" required="true" maxlength="64" label="SKU" default_attribute="sku"/>
        <field name="name" required="true" maxlength="200" label="Name" default_attribute="name"
               default_modifiers="strip_tags|truncate:200"/>
        <field name="price" required="true" label="Price" default_resolver="price"/>
        <field name="stock" required="true" values="in stock,out of stock" label="Stock"
               default_attribute="stock_status" default_dictionary="Availability (space-separated)"/>
        <field name="condition" values="new,used" label="Condition" default_value="new"/>
        <field name="ean" label="EAN"/>
    </catalog>
</catalogs>

Then clear the configuration cache, where the merged catalogs are kept:

bin/magento cache:clean config

Example Shopping is then in the feed form's Type list. A feed of that type is mapped and delivered like any other: the channel decides where it goes, the catalog only what it holds.

The catalog element

Attribute Value
type Required. The code a feed stores: lower-case letters, digits and underscores, starting with a letter. Keep it once a feed uses it.
label What the form and the grid show. Without it, the code with spaces and capitals: example_shopping shows as Example Shopping.
icon The image the grid's Type column shows before the label, in a white circle: a file under your module's view/adminhtml/web, as Vendor_Module::path. A square SVG reads best. Without it, the generic type's icon.
format The expected writer alias, such as csv_semicolon or heureka_xml. Changing Type preselects it in Format when the writer is registered; opening a saved feed keeps its format. When both writers are registered and the saved format differs, a file channel warns and continues: The feed type "Heureka" expects the Heureka XML format; this feed writes CSV. See Writers and European marketplaces.
taxonomy The category tree for this feed type, named by its code in Arlanix\ProductFeed\Model\Taxonomy\Sources. The module registers google, heureka, zbozi and glami. If the attribute is absent or its code is unregistered, Catalog::getTaxonomy() returns google.
xml_namespace, xml_prefix The namespace an XML feed of the type puts its fields in, and its prefix: http://base.google.com/ns/1.0 and g in the Google Shopping catalog. RSS's own title, link and description stay outside it. A prefix needs a namespace. Only heureka_xml writes a namespace without a prefix as the default namespace. For zbozi, it writes xmlns="http://www.zbozi.cz/ns/offer/1.0" on SHOP. Without either, fields have no namespace.

The field element

Attribute Value
name Required. The target field name in the mapping. The writer or push adapter decides how to send it.
required true marks the field as required in the catalog. Copy from ticks Required on its row, and a run warns about a product whose value is empty when the row is not ticked. One coverage warning lists all required catalog fields that have no mapping row. A push retry that maps no rows emits no coverage warning.
maxlength The longest text the catalog allows, in characters. For a list, the limit applies to each member. A run warns about a longer value and suggests a truncate modifier.
values Comma-separated values the catalog allows. Spaces around each entry are dropped. The check compares the mapped text exactly, including case, and joins a list with commas before comparing it. A nonblank value outside the list gives a warning.
label The field's name in messages. Without it, name.
default_resolver The alias of a resolver that Copy from sets as the row's source, such as price. See Resolvers.
default_attribute The attribute Copy from sets as the row's source, such as sku or parent.sku.
default_value The fixed value or template Copy from sets as the row's source, such as new or {name} {color}.
default_dictionary The name of the dictionary Copy from attaches to the row, as Arlanix → Product Feed → Dictionaries shows it.
default_modifiers The modifiers Copy from puts on the row, as they are typed in the mapping: strip_tags|truncate:5000. See Modifiers.

What Copy from builds

Copy from adds one mapping row for each field that is required, has a default source, or names a dictionary, in the order the catalog lists them. Fields with none of these are left for the store to add.

A row's source is the first of default_resolver, default_attribute and default_value that the field sets. A resolver's arguments are left empty: an argument, such as an image size, is a choice about the store's own feed, and the row shows the control for it.

A default_dictionary is looked up by name when Copy from runs. If no dictionary has that name, the row gets none, without a message. Ship the dictionary with your module, in a data patch through Arlanix\ProductFeed\Api\DictionaryRepositoryInterface, or ask the store to create it under Arlanix → Product Feed → Dictionaries before they copy.

Copying is the only time the defaults are read. A feed's saved mapping is its own; changing a default changes the next copy, not existing feeds. The mapping engine checks required, maxlength and values after applying the modifiers. A push channel retry reuses the validation result stored with the row.

Change a field of another catalog

Files are merged by catalog type, then by field name, so a catalog in your module can change one attribute of a field another module declares. For example, to make Copy from read the brand of a Google Shopping feed from an attribute named brand:

<catalogs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="urn:magento:module:Arlanix_ProductFeed:etc/feed_catalog.xsd">
    <catalog type="google_shopping">
        <field name="brand" default_attribute="brand"/>
    </catalog>
</catalogs>

The field keeps every other attribute it had. Your module must load after Arlanix_ProductFeed, through <sequence> in its etc/module.xml, for its value to win; see Extend the module.