1

We need to create a custom data import in Magento 2. In Magento 1 we used to use the Dataflow model to implement our custom imports.

In Magento 2 there are no 'advanced profiles' but an 'Import' section. Does anyone know if it's possible to add new custom entities to that import section? Any examples?

Thanks!

4

You can create a custom import with Magento 2.

You can based on the CatalogImportExport or CustomerImportExport Magento module which is based on the ImportExport Magento module as a reference.

Basic step :

  • Create your CustomImportExport Module
  • Add an import.xml configuration file
    • Add your entity model and behavior
    • Add your entity type if needed
    • Add the relatedInxexer to refresh after import
  • Implement your import model with your logic

Code Examples:

import.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_ImportExport:etc/import.xsd">
    <entity name="catalog_product" label="Products" model="Magento\CatalogImportExport\Model\Import\Product" behaviorModel="Magento\ImportExport\Model\Source\Import\Behavior\Basic" />
    <entityType entity="catalog_product" name="simple" model="Magento\CatalogImportExport\Model\Import\Product\Type\Simple" />
    <entityType entity="catalog_product" name="virtual" model="Magento\CatalogImportExport\Model\Import\Product\Type\Virtual" />
    <relatedIndexer entity="catalog_product" name="catalog_product_price" />
    <relatedIndexer entity="catalog_product" name="catalogsearch_fulltext" />
    <relatedIndexer entity="catalog_product" name="catalog_product_flat" />
</config>

Behavior module

Magento\ImportExport\Model\Source\Import\Behavior\Basic

Product Import model example :

Magento\CatalogImportExport\Model\Import\Product
  • Any idea how to import export categories in csv same as product via backend? – Kirti Nariya Jun 11 at 9:16
  • I have added Entity Type "catalog_category" in export.xml and displaying in Entity Type drop down. But issue in Vendor\CategoryImportExport\Model\Export\Category.php files not working properly. – Kirti Nariya Jun 11 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.