Akeneo DataImporter - how the ImporterPlugin should look like?


#1

on https://documentation.spryker.com/content/industry_partners/performance/akeneo/akeneo-integration.htm?Highlight=akeneo
we can see:

Lastly, you should implement data import plugins for writing data (categories, attributes, abstract and concrete products) into the shop.

and I believe this is about implementing functions which only return container, like addProductAbstractDataImporterPlugin on:

However, there’s no indication on how those plugins should look like. Even if we will add:

class ProductAbstractDataImporterPlugin extends AbstractPlugin implements DataImporterPluginInterface {
    public function import(array $data): void
    {
        $this->getFacade()
            ->importModelProducts($data);
    }
}

the Facade method contains:

public function importModelProducts($data){
        $this->getFactory()
            ->createAbstractProductDataImporter()
            ->import();
    }

and the BusinessFactory is

class AkeneoPimMiddlewareConnectorBusinessFactory extends OriginalAkeneoPimMiddlewareConnectorBusinessFactory
{

    /*note, most of those methods come from src/Pyz/Zed/DataImport/Business/DataImportBusinessFactory.php */

    public function createAbstractProductDataImporter(){
        $dataImportBusinessFactory = new DataImportBusinessFactory();
        return $dataImportBusinessFactory->createProductAbstractImporter();
    }
}

because:

  1. createProductAbstractImporter from https://github.com/spryker-shop/suite/blob/master/src/Pyz/Zed/DataImport/Business/DataImportBusinessFactory.php seems to be reading the CSV, while Akeneo is JSON. How to tell it to use JSON that akeneo fetches?
  2. import method, according to \Spryker\Zed\DataImport\Business\Model\DataImporterDataSetWriterAware needs DataImporterConfigurationTransfer, how do we get Akeneo Abstract Product importer config?
  3. Even if I provide it with:
public function importModelProducts($data){

        $dataImporterConfigurationTransfer = new DataImporterConfigurationTransfer();
        $dataImportReaderConfigurationTransfer = new DataImporterReaderConfigurationTransfer();
        $dataImportReaderConfigurationTransfer->setFileName(APPLICATION_ROOT_DIR . '/data/import/maps/product_models.json');
        $dataImporterConfigurationTransfer->setReaderConfiguration($dataImportReaderConfigurationTransfer);

        $this->getFactory()
            ->createAbstractProductDataImporter()
            ->import($dataImporterConfigurationTransfer);
    }

It still doesn’t write anything to the database.

How do I proceed here to actually import the data? If I use the Importer Class as Importer, I can use ProductAbstractWriterStep as a extra step and pass the data. But how do we do this with the DataImporter which for writes seems to be using DataSetWriterCollection?


#2

Hi! https://documentation.spryker.com/content/spryker-middleware.htm Spryker has Data Import Plugins and Business Logic section there which describes creation the plugins, the importers, the write stream etc. I think it can be helpful for you


#3

@volodymyr.hrychenko so I followed it (except the places where akeneo in SprykerEco namespace already had it implemented and got to this:

none of this imports the data. Can you please clarify what the doc was not precise about?