The add-on XC\AutoImportBase provides building blocks for Auto data provider integrations. The add-on provides basic classes for Controller, View, Model, helper classes facilitating the import of various data (MMY-fitments, attributes, images, categories) and an abstraction layer for performing data import in the background (i.e. without the need to keep the import page open) in a daemon process.
To enable import to work in the background:
- Enable
FORCE_AUTOIMPORT_BACKGROUND_JOBS_ENABLED
в.env.local
- Complete some configuration related to queues. In our example, we are using the name
async_my_awesome_provider_commands
, but you can use a different one - just be sure to use your chosen name consistently in place of ours.
services:
XC\AutoImportBase\Messenger\Handler\ExecuteCommandHandler:
tags:
- { name: messenger.message_handler, transport: async_my_awesome_provider_commands }
framework:
messenger:
transports:
async_my_awesome_provider_commands:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
serializer: XCart\Messenger\Serializer
options:
queue_name: my_awesome_provider
routing:
'XCExample\AutomotiveImportExample\Messenger\Message\ExecuteCommand': async_my_awesome_provider_commands
You will need to run the command php bin/console messenger:consume -vvv async_my_awesome_provider_commands
and ensure that the consuming process is run continuously.
For use of scheduling, configure periodic execution of X-Cart's script for periodic and scheduled tasks (bin/console xcart:cron
)
A basic integration includes the following:
- A page for the integration settings.
- A list of brands. It is possible to import products associated with a specific brand and to configure a specific brand.
- The page with the settings of a specific brand allows the user to configure repeat imports based on a certain schedule (for example, once a week, or once a day for 10 days). The page can be extended with more settings, if necessary.
- Import results pages providing lists of products that have been imported successfully and products for which import has failed (with detailed error descriptions for failed imports).
Integration settings
Integration settings page, with the ability to choose import mode and the ability to add more settings (for example, API Token).
\XC\AutoImportBase\Controller\Admin\ASettings
\XC\AutoImportBase\View\Tabs\MainTabs
\XC\AutoImportBase\View\Page\Admin\ASettings
Brand list
Automotive brands list page. A brand is an entity for grouping products together; it may be related to ShopByBrand
but it is not the same thing as the ShopByBrand
brand.
\XC\AutoImportBase\Controller\Admin\AImport
\XC\AutoImportBase\View\ItemsList\Model\ABrands
\XC\AutoImportBase\View\Tabs\MainTabs
\XC\AutoImportBase\View\Page\Admin\AImport
\XC\AutoImportBase\Model\Brand
\XC\AutoImportBase\Model\Repo\Block
Brand settings
Brand settings page
\XC\AutoImportBase\Controller\Admin\ABrandSettings
\XC\AutoImportBase\View\Model\AMainBrandSettings
\XC\AutoImportBase\View\Page\Admin\ABrandSettings
Brand import statistics
Pages with lists of successfully imported products and products for which import has failed
\XC\AutoImportBase\Controller\Admin\ABrandUnimportedProducts
\XC\AutoImportBase\Controller\Admin\ABrandImportedProducts
\XC\AutoImportBase\View\ItemsList\Model\AUnimportedProducts
\XC\AutoImportBase\View\ItemsList\Model\AImportedProducts
\XC\AutoImportBase\Model\Repo\ImportProduct
Import
Import process
A level of abstraction is provided to enable the execution of commands in the background. The commands can be either run immediately:
(new MyCommand())->execute();
or queued:
use \XC\AutoImportBase\Core\Traits\CommandsGatewayTrait;
$this->getCommandsGateway()->scheduleCommand(
new MyCommand($someInputData),
ExecuteCommand::class
);
\XC\AutoImportBase\Controller\Admin\AImport
\XC\AutoImportBase\Model\ImportStatistic
\XC\AutoImportBase\Model\ImportProduct
\XC\AutoImportBase\Model\Repo\ImportProduct
\XC\AutoImportBase\Model\Metadata
\XC\AutoImportBase\Model\Repo\Metadata
XC/AutoImportBase/src/Core/Data/Helper/*
- a group of helpers for the creation of X-Cart entities (like attributes, fitments, categories, etc.)\XC\AutoImportBase\Core\Command\CommandWithBatcher
- a basic command that provides a set of methods that facilitate the implementation of data import in batches.\XC\AutoImportBase\Core\Command\LoadProductResourcesCommand
- a basic command for the uploading of files to X-Cart.\XC\AutoImportBase\Core\Scheduler\ITopMessageScheduler
- a mechanism for adding and displaying the TopMessage from background processes.