How to Import Custom CSV to Custom Table in Magento 2

- E-Commerce, Fire development, Magento 2

Magento 2 import export debug log

Recently, we discovered an exciting topic that wasn’t highlighted in our Cookbook. Bilal Usean asked the community how to import a custom CSV file to a custom table in Magento 2. Although community members provided several ways to achieve this goal, we didn’t find any user-friendly solution aimed at people with less technical skills than required by the most rated answer. Variants discussed on StackExchange seem to be highly efficient but too complicated. However, there is one more way to import a custom CSV file to a custom table in Magento 2 with the minimum headache. Below, we provide the original answer as well as our alternative solution. 

'

How to Import Custom CSV to Custom Table in Magento 2 (Guide for Technical Specialists)

Atish Goswami suggests extending the Magento 2’s default import functionality as follows. First of all, he proposes to register a new custom module. At this point, users with not enough technical skills understand that the provided solution won’t help them unless they ask technical specialists for help. But let’s return to our mutton – the new module called “Custom Import.” 

You have to create a module.xml file under app/code/Foo/CustomImport/etc/module.xml. Use the following snippet:

Now, you can proceed to the second step on your way to importing a custom CSV file to a custom Magento 2 table. It is necessary to create another new file – import.xml. This time, you should save it under app/code/Foo/CustomImport/etc/import.xml. Use the following snippet:

Where

  • behaviorModel is aimed at the class name of the model class responsible for handling the import logic;
  • label is a label name of the dropdown option;
  • name is a name for the dropdown option value.

What do we have now? The steps described above add a new option to the “Entity Type” dropdown under System->Data Transfer->Import.

Unfortunately, it is not the end. You still have to create a model file under app/code/Foo/CustomImport/Model/Import/CustomPricing.php. Use this snippet:

The author of the answer recommends taking the reference of Magento_AdvancedPricingImportExport to get a better understanding of the import logic. What to do next? How to import a custom CSV file to a custom table in Magento 2? It seems that you can use the standard Magento 2 import tool to do that. 

Unfortunately, this method looks quite complicated. Another similar solution is provided by the author of the question. You can find it described here: Magento 2 programming: implement import with (import.xml). The article offers even more details but looks complicated as heal for non-technical users. If you still have no idea on how to transfer a custom data file to your Magento 2 website, here is our recommendation. 

How to Import Custom CSV to Custom Table in Magento 2 (Guide for Everyone)

If you are a non-technical user, you won’t be able to implement the method described above due to the lack of understanding of various nuances. Luckily, there is a solution that completely replaces the necessity to master coding when you need to import a custom CSV file to a custom Magento 2 table. Furthermore, you get the ability to import files of other formats even if they are packed into an archive. Meet the Improved Import & Export Magento 2 extension – your number one tool when it comes to data transfers. 

With this module, you can easily import any custom CSV file to any Magento 2 table within just a few clicks:

  1. Create a new import profile; 
  2. Choose a schedule of updates;
  3. Specify an entity you want to import;
  4. Configure import behaviour;
  5. Map third-party attributes to ones used on your e-commerce website. 

That’s it! Just do these five simple actions, and you are ready. Note that the extension saves and applies created profiles to all further updates. It means that you configure it only once (per entity per integration). Next, Improved Import & Export transfers your custom CSV file to a custom Magento 2 table automatically.  

If you need any customisations – contact our support. We will help you choose the exact solution that suits your business needs and provide several ways of customising the basic functionality of our plugin.

More Features to Improve Import Processes

Now, let’s take a look at other features that enhance the default import (and export) processes providing the ability to connect to any external system.

The Improved Import & Export Magento 2 extension provides advanced options when it comes to the automation of data transfers. It lets you create cron-based schedules or use triggers to launch import/export processes automatically. Thus, you no longer need to participate in importing custom CSV files to Magento 2. 

Magento 2 CMS Blocks

Mapping is another feature that enables custom data files import to Magento 2. With Improved Import & Export, you can apply mapping presets, replacing all third-party attributes with ones used internally in a fully automated mode. Thus, the module edits any custom data file from a third-party system, making it suitable for Magento 2.

Magento 2 CMS Blocks

If a preset you need is absent, Improved Import & Export offers an interface where you can do everything manually. The procedure is quite simple: you choose a third-party attribute and specify a replacement. 

Besides, you can map and edit attribute values and third-party categories. In addition to that, the Improved Import & Export Magento 2 extension enables you to create attributes on the fly. Even if your custom CSV file lacks some attributes, our module will still transfer it to your Magento 2 website, recreating the missing data.

And, of course, our plugin dramatically extends the number of supported file formats and sources. You can freely leverage API connections and intermediary services to transfer data from third parties.

As for the supported entities, they include:

  • Products;
  • Categories;
  • Customers and Addresses;
  • Advanced Pricing;
  • Product Attributes;
  • Orders;
  • CMS Pages;
  • CMS Blocks;
  • Catalog & Cart Rules;
  • Gift Cards;
  • Reviews;
  • URL Rewrites;
  • Search Terms and Synonyms;
  • Widgets;
  • Page Hierarchy.

It means that you can freely transfer a data file that contains them. Also, note that we add more entities with every new extension update.

In addition to CSV, you can also import:

  • XML
  • Json
  • XLSX
  • ODS
  • ZIP & TAR

With XML and CSV file format support, Improved Import & Export eliminates the necessity to convert tables your suppliers provide. Furthermore, you can import any XML file to Magento 2 with XSLT support. Our module lets you transform XML files into the format appropriate for import procedure based on XSLT instructions.

It is also possible to import Json to Magento 2. This feature enables Rest API transfers and opens further opportunities than the default import tool offers.

The ability to import Excel and OpenOffice formats to Magento 2 incorporates the extension’s support for XSL, XSLX, and ODS tables. If your partner stores the necessary data in Excel and OpenOffice tables, there is no need to convert them to CSV to import different entities to Magento 2. 

Last but not least, the Improved Import & Export Magento 2 extension provides support for ZIP & TAR archives. There is no need to extract a custom CSV table from an archive before importing it to Magento 2. You can import files of the supported formats even when they are compressed.

The module lets you import a custom CSV file to Magento 2 from the following sources:

  • REST and SOAP API;
  • Google Sheets;
  • Direct URL;
  • FTP/SFTP;
  • Dropbox;
  • Direct File Upload.

We will add new sources within further updates. 

You can also enhance the functionality of our module with the help of the following add-ons:

  • MSI Add-on lets you work with entities added to Magento 2.3 with official Multi-Source Inventory extension. You can freely import and export such data as warehouses and product quantity per warehouse.
  • B2B Add-on provides the ability to work with entities added to Magento Commerce (Cloud) with official B2B extension. It means that you can import and export companies, shared catalogs, quotes, negotiable quotes, and requisition lists.
  • WooCommerce Migration Add-on enables seamless migration from WordPress to Magento 2. No programming skills are necessary since the add-on allows importing WooCommerce products, customers, addresses, and orders to Magento 2 within just a few clicks.
  • MS Dynamics Integration Add-on enables the Magento 2 MS Dynamics Business Central ERP/CRM integration. The extension synchronises products, orders, customers, shipping, and invoices between the two systems.
  • NetSuite Integration Add-on offers similar opportunities to the ones we just described above.
  • Banggood Dropshipping Add-on introduces the easiest ways to start a dropshipping business with Magento 2. The add-on lets you connect your e-commerce store with the Banggood catalog, synchronising products, orders, shipping details, etc. Now, you can sell products without a warehouse.

You can find more add-ons here: Magento 2 Extensions by Firebear.

Final Words

As you can see, Improved Import & Export is a very potent tool for transferring data between your Magento 2 website and any external systems. Of course, it can easily import a custom CSV file to a custom Magento 2 table in a very user-friendly way. No coding skills are required! For further information, follow the link below and contact our support:

Get Improved Import & Export Magento 2 Extension

'