Product import: FAQ
Overview
This page answers frequently asked questions about error cases and the behaviour of the product import as of version 3.0.0 of the plugin. The structure, hooks and helper methods of the import are described on the page "Product import", the underlying rules in the section "Error handling and partial import". Starting from a symptom, the page "Troubleshooting" leads to cause and solution.
The messages in the report are written in English and are quoted here in their original wording. <id> stands for the readable ID (Pimcore ID) of the entry.
Report and partial import
What does the journal show?
Every package with messages gets one chapter in the journal (.done) with the messages of the current file:
| Level | Examples |
|---|---|
INFO | Record <id> was inserted/updated, Record <id> was deactivated instead of deleted, moves of variants |
WARNING | Skipped entries, truncated or not written values, unresolvable references |
ERROR | Skipped batches, failed deactivation blocks, abort of a package |
The context of a message is the readable ID of the entry. Variants are reported at their main product, e.g. (ID: "4711-1", Parent-ID: "4711").
What happens if a batch cannot be written?
Shopware writes a batch (getBatchSize(), by default 75 main products including their variants) in one transaction. If the write fails despite the pre-check, e.g. because of a validation error or a foreign key, the batch is rolled back completely and an error is reported:
Batch was skipped because it could not be written, affected records: 4701, 4702, … Cause: record 4711, field "taxId" (product-upsert): …
The cause names the entry and the field if Shopware provides them. Errors of manufacturers, units and delivery times name the referencing product and the name. The import continues with the next batch, the deactivations and the following packages. Entries of the skipped batch are not deactivated as stale. The batch is only written again when its entries are delivered again – with delta exports, re-export the entries listed in the error. After a failed batch, the cached IDs (existing products, manufacturers, units, delivery times) are reloaded. Cross-sellings are written in batches of 20 products, category assignments per category.
Is a failed batch retried product by product?
No. The whole batch is skipped, there is no sync per product. Correct the data in the source system and deliver the entries again. The import does not remember failed entries, with delta exports re-export the entries listed in the error.
What does "Batch was written, but post-processing failed" mean?
Shopware has already committed the batch, afterwards a listener of the write event threw an exception (e.g. a subscriber of another plugin or a synchronous indexer). The data is in Shopware, the entries count as imported and deactivations as well as moves are processed normally. Only the messages inserted/updated of this batch are missing. The cause is part of the message, a re-indexing (dal:refresh:index) may be necessary.
Which errors still abort the whole file?
Connection losses, deadlocks after the retries of Shopware, a transaction that is still open after the error and programming errors (\Error, TypeError). The module then adds the error Import of package "<package>" was aborted: <message> to its chapter, the chapter is still written to the journal. The file ends with the resolution error, the following packages are not imported.
Which resolution does a file with skipped entries have?
success. Skipped entries and batches are only reported in the journal as warning or error. To monitor the import, evaluate the messages, not only the resolution.
Why does a long-running worker no longer show messages of earlier files?
Each import starts with a new, empty chapter per module (resetReport()). Set the logger of the report via setReportLogger(), a logger set via getReport()->setLogger() is kept as well. Because import() replaces the chapter, read getReport() only after import() – a chapter fetched before is no longer filled.
Is the import suitable for large catalogues?
Yes. Existing IDs (products, rules, options etc.) are loaded once per import and checked with a hash lookup, product numbers with one query per batch and the readable IDs of a deactivation block with one query per table. After a failed batch, the cached IDs are reloaded once (one query per entity), so many failed batches slow down the import.
Required data and validation
Which data is required?
Main and simple products: id, uuid, product-number, tax, price {net, gross} (numeric) and translations with a non-empty name in every delivered language – for every delivery, i.e. also for updates. A new main or simple product additionally needs a name in the system language. Variants only require id, uuid and product-number, they inherit tax, price and names (see "Variant inheritance").
If required data is missing, the entry is skipped with a warning (Field "<field>" is not valid in record <id> and a more specific message). An invalid main product is skipped including its variants, an invalid variant only itself (Variant skipped because of invalid fields "<field>") – it is not deactivated and keeps its options. A skipped entry and its delivered variants remain unchanged in Shopware and are not deactivated as stale. Optional fields (e.g. delivery-time, purchase-price, canonical-product, cms-page, feature-set, variant-listing-config) never skip the entry – an invalid or unresolvable value is reported and not written.
What happens if the name is missing?
A missing or empty name in a delivered language (or missing translations) skips a main or simple product. A new product without a name in the system language is skipped with Product skipped because a new product needs a name in the system language. A variant without name in a delivered language gets the name null there and inherits the name of its main product, a variant without translations keeps its current names (a new variant inherits them). If the name is delivered under another locale key, check the locale keys of the export and the languages in Shopware. Short forms like de are mapped to a Shopware locale by the service JsonImportConfiguration (getLocaleMapping()).
Which locales are accepted?
The keys of translations (as well as of description of a manufacturer and name of a delivery time) are mapped to the locales of the Shopware languages by JsonImportConfiguration::getLocaleMapping(). This is a service, not a plugin configuration – the mapping is changed in the project in code: either extend or decorate Twocream\JsonImporter\Core\System\Import\Configuration\JsonImportConfiguration (service id twocream.json_importer.configuration) or subscribe to LocaleMappingEvent::NAME (Twocream\JsonImporter\Core\System\Import\Event\LocaleMappingEvent). The event is dispatched once per ModuleService instance (in practice once per worker process) with the mapping of the service and the locales of the Shopware languages (getShopLocales()), the result of setLocaleMapping applies to all following imports. The subscriber is registered as service with the tag kernel.event_subscriber.
class LocaleMappingSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [LocaleMappingEvent::NAME => 'onLocaleMapping'];
}
public function onLocaleMapping(LocaleMappingEvent $event): void
{
$event->setLocaleMapping(['de' => 'de_DE', 'en' => 'en_US'] + $event->getLocaleMapping());
}
}
The language mapping of the Pimcore connector (language_mapping in shopware_connector.yaml) runs before – keys that Pimcore already exports as Shopware locale (e.g. en_DE) are not mapped again.
| Key | Behaviour |
|---|---|
de, en (Pimcore) | By default de => de_DE and en => en_GB |
Shopware locale with underscore (de_CH) | Is taken over unchanged |
Key with a hyphen (de-DE) | Is ignored |
| Locale without a language in Shopware | Is ignored |
A new product whose name is only delivered under ignored keys has no name in the system language and is skipped. Use Shopware locales with an underscore as delivered by the product export via language_mapping (e.g. "translations": {"de_DE": {"name": "…"}}) or the short forms of the mapping (e.g. de).
What happens with a missing or unknown tax rate?
A missing or null tax skips a main or simple product. For a variant, null inherits the tax rate of its main product – a null never resolves to 0 % –, a missing key keeps the current tax rate of the variant. Variants without own tax rate therefore have to deliver null. A tax rate that does not exist in Shopware or is not a number skips the entry with Tax rate can not be detected. Taxes are never created.
Are 0 % and 7.7 % tax detected?
Yes. The tax rate is read like other numbers (see What happens with invalid numbers?) and compared as a decimal number with a tolerance of 0.001, so 0, 7.7, "7.7" and "7,7" are found. If several taxes have the same rate, the first by position wins.
What happens with a missing or too long product number?
A missing product number or one that only consists of spaces skips the entry. A product number with more than 64 characters skips the entry as well – it is not truncated, because a truncated number could collide with another product.
Is a price of 0 valid?
Yes. price {net: 0, gross: 0} is a valid default price and a rule price with net: 0 is written. Default and rule prices are read like other numbers, so "1,5" results in 1.5. A default price that is not a number (e.g. "abc") skips the entry. A rule price that is not a number or negative is reported as a warning (Price is not a valid number (numeric, not negative), the current rule price is kept), the existing rule price of the market remains unchanged.
Adjusted and not written values
What happens with too long texts?
Texts that are longer than the Shopware field allows (e.g. name, meta-title, meta-description, pack-unit, manufacturer-number, ean) are truncated and reported as a warning (Field "<field>" was truncated to <n> characters). Truncating is multibyte-safe, translations are reported with their locale, e.g. translations/de_DE/name. Short text fields (e.g. name, meta-title, ean) are written without leading and trailing spaces, long texts like description remain unchanged. The product number is never truncated (see above).
What happens with invalid numbers?
An invalid integer or number is not written, Shopware keeps the current value (warning … was not written because value … is not a valid …, the current value is kept). Accepted are:
| Type | Examples |
|---|---|
| Integers | 10, "10", 10.0, "1.000.000" |
| Numbers | "1,5", "1.234,56", "1,234.56", "1'234.5", "1 000" |
A single . or , is a decimal separator, so "1.000" results in 1.0.
What happens with invalid booleans?
Accepted are true/false, 1/0, "yes"/"no", "ja"/"nein", "on"/"off", "y"/"n" and "j". Other values (e.g. "maybe") are not written and reported as a warning, the current value is kept. This also applies to active.
What happens with invalid dates?
Accepted are ISO 8601 (with or without time zone and microseconds), Y-m-d, Y-m-d H:i[:s] and d.m.Y [H:i[:s]]. Without a time zone, the time zone of PHP applies. Invalid dates (e.g. 31.02.2024 or n/a) are not written and reported as a warning, an empty string removes the date.
What happens with purchase-steps: 0 or min-purchase: 0?
Both values must be at least 1. A smaller value is not written and reported as a warning, the current value is kept.
What happens if max-purchase is lower than min-purchase?
max-purchase is not written and reported as a warning. If min-purchase is not delivered, it is compared with 1.
Is a negative stock allowed?
Yes. An invalid stock (e.g. "abc" or a value outside the integer range) is reported as a warning and handled like a missing key: 0 for new products, unchanged for existing products, the current stock for a detached variant.
What happens with an invalid EAN?
An EAN without a valid GTIN check digit (EAN-8, GTIN-12/13/14) is only reported as a warning and imported anyway. An EAN delivered as a number is written as text.
Which limits of the database are checked?
Integers outside -2147483648 to 2147483647 as well as width, height, length and weight outside [0, 10000000) are not written and reported as a warning. Texts are checked against the length of the field (see above). Different value ranges can be passed to the PayloadSanitizer as $floatRanges by overriding getPayloadSanitizer().
What happens with an invalid entry in a list?
An entry of a list (visibility, rule price, translation, delivery time) whose required value is invalid is dropped completely, e.g. Entry "visibilities/0" was not written because its required field "visibility" has the invalid value "all". The existing entry in Shopware remains unchanged, the rest of the product is written. A visibility without visibility is written with 30 (all).
Product numbers
What happens if the same product number occurs twice in the file?
The first entry wins, even if it is skipped itself. A later entry with the same number and another UUID is skipped with Product skipped including its variants because product number "…" is already used by record <id> in this import file, for a variant with Variant skipped because … only the variant itself. Surrounding spaces and the case are ignored in the comparison. Existing products affected by the conflict remain unchanged and are not deactivated.
What happens if the product number already belongs to another product in Shopware?
The entry is skipped with … is already used in Shopware by product <id> (UUID: "…"). The other product is often a deactivated product, e.g. because it was deleted in the source system and created again with a new ID. Free the number in Shopware (change the product number of the old product) or correct it in the source system.
If the other product gets another product number in the same file (i.e. it releases the previous number), there is no conflict: if it is written in an earlier batch, the number is already free. If it is not written yet (same or later batch, or deferred itself), the entry (including its variants) is deferred and processed again once after all batches with the same check. Swapping the product numbers of two products is not supported – both still hold the number of the other one and are skipped with the hint the product number is still used by another delivered product that could not be written first (e.g. swapped product numbers), use a temporary product number in the source system. In this case, use a temporary number in the source system for one of the products for one import first.
What about product numbers that only differ in accents?
The pre-check only ignores spaces and the case. Numbers like CAFÉ-1 and CAFE-1 are equal for the database (utf8mb4_unicode_ci), Shopware rejects the second one and the whole batch is skipped (error with Product with number … already exists). Correct the number in the source system.
Deactivation, reactivation and moving
What happens if a product is deleted in the source system?
The entry {id, uuid, ".meta": {"deleted": true}} deactivates the product and its variants: active = false, its own visibilities are removed and Record <id> was deactivated instead of deleted is reported. Products are never deleted. Categories and cross-sellings are kept unless the project removes them in cleanupDeactivatedProducts(). The deactivation is written in blocks of 100 products, a failed block is reported as an error and remains unchanged. The deactivation is only repeated when the deletion entry (or the main product of a stale variant) is delivered again.
What happens if an entry is deleted and delivered in the same file?
The delivery wins: the product is not deactivated and the warning Record <id> is marked as deleted but was also delivered in this import file is reported. Correct the export.
What happens with a variant that is no longer delivered?
It is deactivated as a stale variant after the import (active = false, own visibilities removed). Afterwards it inherits the visibilities of its main product, which has no effect as long as it is inactive. A missing key variants and variants: [] deactivate the same variants. Delivered variants are never deactivated as stale, even if they are not written: variants of skipped batches, invalid variants, variants with a product number conflict as well as variants of a skipped main product or of a main product without a valid variant remain unchanged.
How is a product reactivated?
By delivering it again. Without the key active, a main or simple product is written with active = true, a variant with active = null (inherits from the main product). The visibilities are written from the file again. Categories and cross-sellings removed by a project hook only come back if the packages category-assignments and cross-selling deliver them again – with delta exports this is usually not the case.
What happens with products that were deactivated manually in the administration?
A delivered product without active is reactivated, because the source system is leading. If a product has to stay inactive, deliver active: false. Products that are deleted or stale in the source system are cleaned up on every import that contains them as deleted or stale (visibilities, hook), even if they are already inactive – they are not reported again.
How are variants moved?
A product always gets the main product of its entry. A variant under another main product is moved, a variant delivered as a standalone entry is detached and a simple product delivered as a variant is assigned to the main product. Each move is reported as info (Product … was moved from parent … to …, … was detached from parent …, … was assigned to parent …), the previous main product is indexed again. A detached variant has to deliver its complete data, an existing stock is kept. Further details are described in the section "State synchronisation".
Why does the warning "Product has variants in Shopware but is delivered as simple product" appear?
A former main product is delivered without variants. Its variants that are not delivered elsewhere are deactivated, but keep their main product. The product stays a container that cannot be bought until the variants are deleted manually or by a cleanup in the project. The warning is repeated on every import.
Can deactivated products be removed from cross-sellings and categories?
Yes, via the hook cleanupDeactivatedProducts() with the helper methods removeCrossSellingAssignments() and removeCategoryAssignments() (see Example). The hook is called per block of at most 100 products, also for already inactive products, and therefore has to be idempotent. If an operation of the hook fails, the deactivation of the block is rolled back as well (error) and only repeated when the entries are delivered again.
What happens with cross-sellings that become empty as a result?
removeCrossSellingAssignments() deactivates (active = false) cross-sellings of other products whose last assigned product was removed. A later import of the package cross-selling recalculates active.
Relations
What happens if visibilities, properties or prices are missing?
A missing key is handled like an empty list: all existing visibilities, properties or rule prices of the product are removed. A variant without these keys loses its own entries and inherits the values of its main product.
What happens with a market, a currency or a rule that cannot be resolved?
The entry is not linked and reported as a warning per reference (Market can not be resolved, visibility is skipped, Currency can not be detected, Rule does not exist in Shopware, price is skipped). Existing entries that are not part of the resolved set are removed anyway. This differs from an invalid value: a rule price with a resolvable market, rule and currency but an invalid net keeps the existing rule price. Markets that are not supported on purpose can be excluded from the warning in reportUnresolvedMarket().
Why is a rule price in another currency skipped?
Shopware requires a value in the default currency for every price. A rule price whose currency is not the default currency is skipped with Price has no value in the default currency, price is skipped. Prices in several currencies are not supported yet.
What happens with translations of languages that are not delivered?
They are kept. Translations are written per delivered language like simple fields, languages that are not available in Shopware are ignored.
What do variants inherit from the main product?
Everything they do not have themselves: a delivered null of a simple field, of tax, price, manufacturer, unit, delivery-time, purchase-price, canonical-product, cms-page, feature-set, of a translation key or of a custom field inherits, active without key is written as null, a name that is missing in a delivered language inherits, and a variant without visibilities, properties or prices inherits the values of the main product. Only id, uuid and product-number are required. A missing key keeps the current value of the variant – except active (inherits) and properties, visibilities and prices (own entries are removed, the variant inherits) –, so always deliver translations for variants (see "Variant inheritance").
Product extension
How is the product extension written?
Via getProductExtensionFieldMap() and getProductExtensionTranslationKeyMap() of the product module (default [] each, see "Product import: Product extension"). The first map maps keys of product-extension to the fields of the product extension, the second one keys of product-extension.translations.<locale> to the translated fields. The locales of the translations are mapped via prepareTranslation() as for translations (see Which locales are accepted?). The product extension is written with id (UUID of the product) and pimcoreId and is pre-checked like the product.
What happens with missing or unmapped keys of the product extension?
A mapped key that is not delivered is not written – the value in Shopware is kept. An explicitly delivered null is written. Delivered keys without entry in a map are ignored.
Why is no product extension written?
Nothing is written (no row in twocream_product_extension) if both maps are empty, the entry has no block product-extension or none of the mapped keys is delivered. Translations whose locales cannot be mapped to a language in Shopware are omitted as well. Additionally, check whether the definition and the extension are registered in the project (see "Product extension").
How are nested structures of the product extension written?
The keys of the maps are flat, the value is taken over unchanged. Nested structures, relations (e.g., [{id, uuid}]) or converted values require an override of getProductExtensionData() that takes over the result of parent::getProductExtensionData($data), so that the maps still apply (see example).
Where do the keys of the product extension come from?
From the product adapter in Pimcore: buildProduct() delivers them under product-extension or product-extension.translations.<locale> (see "Build a product export"). The keys of the export and of the maps must match.
Master data
How is the delivery time delivered?
delivery-time is either the UUID of an existing delivery time (string or {uuid}) or {min, max, unit, name?} with the unit hour, day, week, month or year:
{ "delivery-time": { "min": 1, "max": 3, "unit": "day", "name": { "de": "1-3 Tage" } } }
| Case | Behaviour |
|---|---|
Delivery time with the same min/max/unit exists | Is reused (e.g. the default delivery time "1-3 days" of Shopware) |
| No matching delivery time exists | Is created once with the ID md5("delivery-time-<min>-<max>-<unit>"). The name per locale is taken from name, if it is missing in the system language, an English name is generated (1 day, 1-3 days, 2 weeks) |
| Existing delivery time | Is never changed |
| Key missing | The assignment remains unchanged |
null or "" | The assignment is removed (variants inherit) |
Unknown UUID, invalid unit, min > max | Warning, the field is not written |
How is the purchase price delivered?
purchase-price is {net, gross} in the default currency like price ("1,5" is accepted) and is written as purchasePrices (linked: false). Both values must be numeric and not negative, otherwise the purchase price is reported and not written. A missing key keeps the purchase price, null or {}/[] removes it (variants inherit).
How is the canonical product delivered?
canonical-product is {id, uuid} of another product (uuid = Shopware product id). The canonical product must exist in Shopware or be written in the same import – because it may follow in a later batch, the canonical products are written after all batches (writeCanonicalProducts(), one update per chunk of getBatchSize() products, a failing chunk is reported as error). An unknown product, a product that is skipped in this import and does not exist in Shopware, a value without a valid UUID or the product itself are reported and not written. A canonical product that is deactivated by this import (a deleted entry, a variant of a deleted main product or a stale variant) is reported as well (Canonical product "<uuid>" is deactivated in this import) and not written. A missing key keeps the assignment, null, "" or [] removes it (variants inherit). See "Product import: Canonical product".
How are the CMS page and the feature set delivered?
cms-page is the UUID of an existing CMS layout of the type product_detail (PRODUCT_CMS_PAGE_TYPE), feature-set the UUID of an existing feature set (product_feature_set, "Essential characteristics" in the administration). Both are never created, the layouts and feature sets are loaded once per import. An unknown UUID or a layout of another type is reported and not written, a missing key keeps the assignment, null, "" or [] removes it (variants inherit).
How is the variant listing configured?
Main products always get a variantListingConfig with displayParent: true, no main variant and no configuratorGroupConfig. variant-listing-config of a main product overrides single keys of this default:
display-parent(boolean) =>displayParentmain-variant({id, uuid}of a valid variant delivered under this main product in this entry, the UUID wins) =>mainVariantId– Shopware only uses the main variant ifdisplay-parentisfalse(withtruethe main product is shown in listings), the import writes it anywayconfigurator-group-config([{id?, uuid, representation, expression-for-listings}]) =>configuratorGroupConfig([{id, representation, expressionForListings}]):uuidof an existing property group,representationbox,select,imageorcolor,expression-for-listingsboolean (defaultfalse). Controls how the variants are presented in listings (administration: "Product listing" / "Storefront presentation"). A property group delivered more than once is reported, the first entry wins
Keys that are not delivered or null keep the default, null for the whole key writes the default. An invalid value of a key keeps the default of the key, invalid entries of configurator-group-config are dropped and unknown keys are ignored, each with a warning. For a variant or a simple product the key is reported (Field "variant-listing-config" is only supported for main products) and not written. See "Product import: Variant listing".
How is the manufacturer delivered?
As a name ("ACME") or as an object:
{ "manufacturer": { "name": "ACME", "link": "https://www.acme.com", "description": { "de": "…", "en": "…" } } }
The locale keys of description are mapped like those of translations (see Which locales are accepted?). The ID is md5('manufacturer-' . <name>). A missing manufacturer is created with name, link and description, an existing manufacturer is never changed – changes in the administration are therefore kept. An object without a name is reported as a warning and the current assignment is kept, "", null or [] remove the assignment. A project override of getOrCreateManufacturerIdByName() only applies to manufacturers delivered as a name, override getOrCreateManufacturerId() for objects.
How is the manufacturer image set?
Only via the hook getManufacturerMediaId(array $manufacturer, bool $exists): ?string (see Example). The returned media must already exist in Shopware (e.g. via checkDamImage() or ModuleService::createMediaByUrl() with a deterministic ID), otherwise a warning is reported and the image is not written. The image is written for new and existing manufacturers if it differs from the current one. null or '' keep the current image.
How is the unit handled?
unit is the name of the unit. The ID is md5('unit-' . <unit>), a missing unit is created with name and short code, an existing unit is not changed. "" or null remove the assignment.
How are custom fields delivered?
By their technical name: custom-fields.<name> for non-localized values, translations.<locale>.custom-fields.<name> for localized values (the localized value applies in its language). Arrays and objects are values, they are interpreted by the type of the custom field (see "Custom fields").
What happens with an unknown custom field or an invalid value?
Both are reported as warning per entry and not written, the entry is imported anyway. A name is known if it is an active custom field of a set that is related to products. An invalid value (e.g., "abc" for int, an option that is not configured for a select or no UUID for an entity field) keeps the current value.
How is a custom field removed?
With null. Shopware stores the key as JSON null and ignores it when merging the values – a variant inherits the value of its main product again, a language falls back along the language chain (parent language, then system language). With writeUnlocalizedCustomFieldsToAllLanguages() = false, a null in custom-fields only removes the value of the system language. Keys that are not delivered are kept, except keys of the sets of getManagedCustomFieldSets(), which are removed if they are not delivered.
In which languages are custom fields written?
Values of custom-fields in all languages of the shop (writeUnlocalizedCustomFieldsToAllLanguages() = false: only the system language), localized values in their language. Custom fields of other plugins are never changed.
How are additional custom fields and translations of getAdditionalProductData() merged?
translations of the hook (keyed by language ID) are merged per language and field with the translations of the import, translations.<languageId>.customFields per key. Names and custom fields of the import are kept unless the hook returns the same field. Do not return a top-level customFields, it targets the translation of the system language as well.
Does the plugin store ID mappings?
No. The plugin has no tables for ID mappings, the UUID equals md5(<Pimcore ID>) and is delivered by the source system.
What is not supported yet?
- Product media and cover images
- Tags
- Graduated prices, list prices and prices in several currencies
- Lookup of the sales channels by the import itself (implement
getSalesChannelIdByMarket()in the project)