Let’s assume that you need to export a custom entity from Magento 2 as you do with products, orders, and other records. However, the platform doesn’t let you do that by default. The list of supported entities is quite limited. In the following article, we explain how to extend it and achieve your goal. For more useful tips on import and export, follow this link: Magento 2 Cookbook.'
Before going any further, note that we can help you with Magento 2 import and export tasks of any complexity. Our team has considerable experience in transferring all possible data to and from Magento 2.
Table of contents
The default entities are not enough to satisfy the demands of your e-commerce business. Therefore, you’ve created a custom record that suits your business model. However, it is impossible to transfer it by default. What should you do to enable synchronization with external systems and partners?
Additional Details About The Issue
Sunny Rahevar has a simple database table with three fields named ‘manufacturer_manufacturer‘. The corresponding field names are the following: manufacturer, model, and product_ids. Also, the author reports that there is no primary key.
He needs to transfer the above data from the table, adding the appropriate option in the dropdown. Selecting the custom ‘manufacturer‘ entity should export all the data in the CSV format.
First of all, you need to add the export.xml file in your module’s etc directory. Olubajo provides the following example of the file’s content:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_ImportExport:etc/import.xsd">
He also points to the fact that your export model class should extend the \Magento\ImportExport\Model\Export\AbstractEntity class. Besides, your custom tool should override the abstract methods, adding your concrete implementations. According to Olubajo, the export model class, should look as follows:
* Class Manufacturer
class Manufacturer extends \Magento\ImportExport\Model\Export\AbstractEntity
* Permanent column names
const COLUMN_MANUFACTURER = 'manufacturer';
const COLUMN_MODEL = 'model';
const COLUMN_PROD_IDS = 'product_ids';
* Permanent entity columns
* @var string
protected $_permanentAttributes = [
public function export()
// TODO: Implement export() method.
public function exportItem($item)
// TODO: Implement exportItem() method.
public function getEntityTypeCode()
protected function _getHeaderColumns()
protected function _getEntityCollection()
// TODO: Implement _getEntityCollection() method.
The Alternative Way to Export a Custom Entity from Magento 2
If you want to export a custom entity from Magento 2 but don’t want to deal with custom code, you’ve come to the right place. Below, we shed light on a reliable alternative solution.
Meet the Improved Import & Export Magento 2 extension. This module provides the ability to transfer any entities between Magento 2 and all possible external systems. Why is it better than the approach described above?
- You don’t need to create a custom module – it already exists!
- You don’t need to create a custom import solution – it is a part of our extension.
- You can import/export data not only in CSV, but also in lots of other formats, including XML, JSOM, and Excel.
- You can import and export data via a remote or local server, cloud storage, Google Sheets. It is even possible to import it via a direct URL.
- API data exchanges are possible too!
- No manual editing is required! The Improved Import and Export extension offers mapping presets and other similar features that let you create a data output suitable for the requirements of Magento 2 or a platform you provide your custom entity to.
- Numerous add-ons are at your service if you want to automate the Magento 2 integration with external systems and simplify it even more. For instance, this Magento 2 SAP Business One Integration Add-on does all the work for you, reducing a complex integration to just a few clicks.
For further information follow the link below or contact our support:'