Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Latest commit

 

History

History
38 lines (32 loc) · 1.63 KB

2021-10-06-import-with-update-by-mapping.md

File metadata and controls

38 lines (32 loc) · 1.63 KB
title issue author author_email author_github
Import with update by mapping
NEXT-16704
d.neustadt
dneustadt

Core

  • Added update_by json field to ImportExportProfileDefinition to include a mapping from each entity included in the import to a dedicated field which will be used to resolve the primary key from
  • Added UpdateByCollection of UpdateBy instances to contain update_by mapping
  • Changed Shopware\Core\Content\ImportExport\Struct\Config to receive update_by mapping for creating and serving UpdateByCollection
  • Added PrimaryKeyResolver that will resolve primary keys within records by mappings of UpdateByCollection if provided
  • Changed EntityPipe and ToOneSerializer to call PrimaryKeyResolver::resolvePrimaryKeyFromUpdatedBy before deserialization

Upgrade Information

Added a new constructor argument iterable $updateBy = [] in Shopware\Core\Content\ImportExport\Struct\Config which will become required starting from v6.5.0.

The new parameter is used to pass a mapping from an entity to a single field of the corresponding definition. This mapping is then used to resolve the primary key of a data set. This provides an alternative to using IDs for updating existing data sets.

Before

$config = new Config(
    [['key' => 'productNumber', 'mappedKey' => 'product_number']], 
    ['sourceEntity' => $sourceEntity]
);

After

$config = new Config(
    [['key' => 'productNumber', 'mappedKey' => 'product_number']], 
    ['sourceEntity' => $sourceEntity],
    [['entityName' => ProductDefinition::ENTITY_NAME, 'mappedKey' => 'productNumber']]
);