Hello Magento Friends 👋,

Today I am going to discuss How to Import CSV File to Custom Table In Magento 2. In case you skipped our previous blog, check it out here. How to Configure Flat Rate Shipping Method in Magento 2.

Magento 2 Mobile APP

During the import of the product in Magento 2, some of the data or columns from the CSV file need to be imported to a custom table. So let’s crack up on the implementation to Import CSV file to Custom Table in Magento 2 🚀

Steps to Import CSV File to Custom Table in Magento 2:

Step 1: Create an import.xml file at the following path:

app/code/Vendor/Extension/etc

Now, add the below code:

Step 2: Create file CustomImport.php under app/code/Vendor/Extension/Model/Import folder and add the following code:

Step 3: Create validator interface file RowValidatorInterface.php under app/code/Vendor/Extension/Model/Import/CustomImport folder and add the below code:

Step 4: Create custom_table with columns as ID, Title, and Description.

Step 5: Create CSV using the same columns in the admin panel. System > Data Transfer > Import. Select Custom Import in the Entity Type field.

Conclusion:

Hence, all have successfully implemented to import CSV file to a custom table in Magento 2. In case you face any difficulty while implementing the steps, let me know in the comment part below. Share the article with your friends.

Happy Reading 😊

Magento-development-services

Click to rate this post!
[Total: 10 Average: 4.3]