Download the PHP package pixelant/pxa-pm-importer without Composer
On this page you can find all versions of the php package pixelant/pxa-pm-importer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package pxa-pm-importer
Product Manager Importer
Short information
This extension was for created to make it easier to import products and products data from different sources.
By default it supports import from CSV and Excel files.
!!! If you want to use Excel source additionally install composer package composer req phpoffice/phpspreadsheet
Import configuration is provided by Yaml.
Example configuration and source files
You can find some examples of import configuration and source data structure in next folders:
- Yaml configuration files
EXT:pxa_pm_importer/Configuration/Example/Yaml/ - Source data files
EXT:pxa_pm_importer/Resources/Private/ExampleData/
Usage
How to create import configuration
Create new extension, for example "pm_myimport".
In ext_tables.php add next code:
This will register your extension as import configuration provider.
By default extension will look for configuration files in:
EXT:pm_myimport/Configuration/Yaml
But you can add as second parameter array of custom paths where to fetch YAML files, but these should be under Configuration folder.
Then in your import configuration file you can use your own importers, source providers, data adapter and processors.
Log
Every import execution is saved in separate log file.
By default all log files are saved in typo3temp/var/logs, file prefix is pm_importer_YYYY_mm_dd_hours:minutes:seconds.log
You can change log path in import configuration
Backend module
After import configuration is created you can run it from Backend module "PM importer".
Scheduler
In order to run import from scheduler, create new Execute console commands task. From available commands choose pxapmimporter:import: Import "pxa_product_manager" extension related records.
Task accept next parameters:
- configurations: - Comma list of path to configuration files to run. For ex. "EXT:pxa_pm_importer/Configuration/Example/Yaml/AttributesCsvSample.yaml"
- adminEmails: Notify about import errors - Notify provided emails about import errors
- senderEmail: Sender email - Sender email in case notification email was set
Simple import
If you want to import data from CSV or Excel files and data is not really complex, possibilities of extension should be enough.
In case you want just run some custom configuration, but don't want to create extension for this, you can do it from command line.
Import yaml configuration
You can create new Yaml configuration file with you import configuration somewhere in "fileadmin".
Example:
Configuration parts
Log
In log settings it's possible to set custom path where to write file log and severity.
Source
Source is responsible for reading data from different sources. Currently extension support two import sources:
!!! It's possible to have multiple source. Script will run imports for each source.
Pixelant\PxaPmImporter\Service\Source\CsvSourcePixelant\PxaPmImporter\Service\Source\ExcelSource
CsvSource supports next options:
ExcelSource supports next options:
Import adapter
Every importer require adapter. Adapter should transform raw data from source to associative array.
Also adapter need to prepare data for language layers if there are such.
By default extension has Pixelant\PxaPmImporter\Adapter\DefaultDataAdapter
Adapter require mapping configuration:
Important to set "excelColumns: true" if you are using excel columns letters as column instead of nubmers. Only number or only letters can be used for one adapter configuration.
Use multiple columns to gerenate identifier:
Following configuration would set identifier to '1100101023se1' if column ITEMID is '1100101023' and DATAAREAID is 'se1', useful when no sigle field in source can be used as a unique identifier.
Use adapter filters to filter rows:
Sample usage: I have a single API source with all products I need to import, but they are one row per language and they should be stored in different PID:s. I also need to filter out rows where PROJCATEGORYID doesn't equal 'BE Online' and CAP_CustUniqueItem equals '1'.
Importer configuration
Processors
Processor purpose is to transform data(field value) in a way that it can be set to model property. Processors are responsible for setting value to property.
Extension has next processors out of box:
Simple properties processors:
Pixelant\PxaPmImporter\Processors\BooleanProcessor- boolean values. No parameters.Pixelant\PxaPmImporter\Processors\FloatProcessor- float values. No parameters.Pixelant\PxaPmImporter\Processors\IntegerProcessor- integer values. No parameterPixelant\PxaPmImporter\Processors\StringProcessor- string values. No parameters.Pixelant\PxaPmImporter\Processors\ProductAttributeProcessor- set value for product attribute.Pixelant\PxaPmImporter\Processors\SlugProcessor- update slug field for urls.Pixelant\PxaPmImporter\Processors\DateTimeProcessor- DateTime values.
Configuration example:
-
Simple
-
DateTimeProcessor
-
SlugProcessor
- ProductAttributeProcessor:
Relations(1:1, 1:n, n:m) processors:
Pixelant\PxaPmImporter\Processors\Relation\AttributeOptionsProcessor- transform field value (for ex.'Red,Blue,Green') into attribute options and attach to attribute. Use only for attributes importer.Pixelant\PxaPmImporter\Processors\Relation\CategoryProcessor- transform field value like 'Food,Car' into categories and attach to object.Pixelant\PxaPmImporter\Processors\Relation\RelatedProductsProcessor- transform product identifiers into products and attach to object.
Configuration example:
Files processor
Pixelant\PxaPmImporter\Processors\Relation\Files\LocalFileProcessor- attach file by name.
Configuration example:
Processor validation
Every property may have many validators.
Custom validators should implement instance of \Pixelant\PxaPmImporter\Validation\Validator\ValidatorInterface.
See RequiredValidator for example.
Important that your custom classes implements required interface.
- Adapter implement
Pixelant\PxaPmImporter\Adapter\AdapterInterface - Processor implement
Pixelant\PxaPmImporter\Processors\FieldProcessorInterfacePixelant\PxaPmImporter\Processors\Relation\AbstractRelationFieldProcessoris useful to handle relation like 1:1, 1:n and n:mPixelant\PxaPmImporter\Processors\AbstractFieldProcessorbasic class to work with simple values, like string and numbers
- Source implement
Pixelant\PxaPmImporter\Source\SourceInterface - Importer implement
Pixelant\PxaPmImporter\Importer\ImporterInterfacePixelant\PxaPmImporter\Importer\Importer- basic class for products, categories and attributes import
Import inside YAML
If you have one general configuration, for example product importer mapping, for all your imports and you want to have it in one place, you can create a subfolder inside "Configuration/Yaml", lets call it "imports"
EXT:pm_myimport/Configuration/Yaml/imports
Create "general_conf.yaml" YAML file there with and put configuration there. Then in your import file you can import like below
Developers useful info
During import process Singleton \Pixelant\PxaPmImporter\Context\ImportContext is available with related to import data. See class for more details.
All versions of pxa-pm-importer with dependencies
typo3/cms-core Version ^9.3
symfony/yaml Version *
pixelant/pxa-product-manager Version ^9.5.1