Skip to main content
page last edited on 20 March 2023

Automotive Import Example

Version: 5.5.0

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:

  1. Enable FORCE_AUTOIMPORT_BACKGROUND_JOBS_ENABLED в .env.local
  2. 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:

  1. A page for the integration settings.
  2. A list of brands. It is possible to import products associated with a specific brand and to configure a specific brand.
  3. 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.
  4. 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).

  1. \XC\AutoImportBase\Controller\Admin\ASettings
  2. \XC\AutoImportBase\View\Tabs\MainTabs
  3. \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.

  1. \XC\AutoImportBase\Controller\Admin\AImport
  2. \XC\AutoImportBase\View\ItemsList\Model\ABrands
  3. \XC\AutoImportBase\View\Tabs\MainTabs
  4. \XC\AutoImportBase\View\Page\Admin\AImport
  5. \XC\AutoImportBase\Model\Brand
  6. \XC\AutoImportBase\Model\Repo\Block

Brand settings

Brand settings page

  1. \XC\AutoImportBase\Controller\Admin\ABrandSettings
  2. \XC\AutoImportBase\View\Model\AMainBrandSettings
  3. \XC\AutoImportBase\View\Page\Admin\ABrandSettings

Brand import statistics

Pages with lists of successfully imported products and products for which import has failed

  1. \XC\AutoImportBase\Controller\Admin\ABrandUnimportedProducts
  2. \XC\AutoImportBase\Controller\Admin\ABrandImportedProducts
  3. \XC\AutoImportBase\View\ItemsList\Model\AUnimportedProducts
  4. \XC\AutoImportBase\View\ItemsList\Model\AImportedProducts
  5. \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
);
  1. \XC\AutoImportBase\Controller\Admin\AImport
  2. \XC\AutoImportBase\Model\ImportStatistic
  3. \XC\AutoImportBase\Model\ImportProduct
  4. \XC\AutoImportBase\Model\Repo\ImportProduct
  5. \XC\AutoImportBase\Model\Metadata
  6. \XC\AutoImportBase\Model\Repo\Metadata
  7. XC/AutoImportBase/src/Core/Data/Helper/* - a group of helpers for the creation of X-Cart entities (like attributes, fitments, categories, etc.)
  8. \XC\AutoImportBase\Core\Command\CommandWithBatcher - a basic command that provides a set of methods that facilitate the implementation of data import in batches.
  9. \XC\AutoImportBase\Core\Command\LoadProductResourcesCommand - a basic command for the uploading of files to X-Cart.
  10. \XC\AutoImportBase\Core\Scheduler\ITopMessageScheduler - a mechanism for adding and displaying the TopMessage from background processes.