How import works¶
At any time, a set of data can be imported: products, attributes, users, etc.
For each entity type, as described in Import and Export data, we import a set of entities using a Reader, a Processor and a Writer.
These batch elements mainly use common internal APIs such as
You can write you own imports for your data: Import and Export data
The goal of the Reader is to read data which can be a simple file (CSV, XSLS, YML, etc) or another external source (a database, a web service, etc).
In Akeneo PIM, all the readers implement
File readers are pretty similar, and use the following parameter,
ArrayConverterInterface: The converter converts array data coming from the file to the standard array format. This format is used when we store serialized data, for instance for variant group values or product drafts, and it’s also usable by the
The goal of the processor is to transform array data to PIM Object and validate it (write is the responsibility of the writer).
In Akeneo PIM, all the processors implement
For an import, all processor receive items in the standard array format.
Processors are similar, the most use
Pim\Component\Connector\Processor\Denormalization\Processor. This SimpleProcessor needs parameters:
IdentifiableObjectRepositoryInterface: The repository fetches the object by its identifier from the database if it already exists.
SimpleFactoryInterface: When the object does not exist, the processor uses the factory to create the object. The
SimpleFactoryInterfaceprovides this default object creation behavior.
ObjectUpdaterInterface: The updater updates an existing entity or a new one, with array data using the standard format.
ValidatorInterface: Once updated, the validator checks if the object is valid.
ObjectDetacherInterface: Because Doctrine UOW keeps references of invalid object in memory, the processor need a detacher to remove references of invalid objects.
The goal of the Writer is to write the processed objects into to database.
In Akeneo PIM, all the writers implement
BaseWriter which uses
BulkSaverInterface to save, and
BulkObjectDetacherInterface to detach all objects already written from the Doctrine UOW.
Found a typo or a hole in the documentation and feel like contributing?
Join us on Github!