How to Add Sample File For Custom Entity Import Functionality in Magento 2

This Blog shows you how to create your own new entity type for import data extending the Magento/ImportExport/Model/Import/Entity/AbstractEntity class to import data into the custom module’s table. When you create your own module you need to attached Download sample file to easily manage Import data.  

Current import entities can be found in System > Import:

  • Create import.xml file under the etc/import.xml  

<?xml version="1.0"?>
<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_ImportExport:etc/import.xsd">
<entity name="publicdesign_deliverydateimport" label="Delivery Date Import" model="Publicdesign\DeliverydateImport\Model\Import\Deliverydate" behaviorModel="Magento\ImportExport\Model\Source\Import\Behavior\Basic" />

  • Now you have to create di.xml in etc folder, etc/di.xml 

<?xml version="1.0"?>
<config xmlns:xsi=""
<type name="Magento\ImportExport\Model\Import\SampleFileProvider">
<argument name="samples" xsi:type="array">
<item name="publicdesign_deliverydateimport" xsi:type="string">Publicdesign_DeliverydateImport</item>

  • Now create a function in Model file, a path for module based on the import.xml file model attribute, Publicdesign\DeliverydateImport\Model\Import\Deliverydate.php 

public function getEntityTypeCode()
return 'publicdesign_deliverydateimport';

  • Now create one CSV file inside the below path

Publicdesign/DeliverydateImport\Files\Sample\publicdesign_deliverydateimport.csv file, CSV file contains the Sample data you have to import.

  • In admin go to System -> Data Transfer -> Import  

Select the new entity you have created and click download sample file; file is downloaded with sample data. 

Data Transfer Import


Now you click on Download Sample file with your new entity option selected, the file will download with your sample data. 

This blog is written by Urvi Sheth, Magento Developer at TridhyaTech