I have to need import export categories in csv same as product, in Magento 2 provided same thing for product.

I have tried below code but facing issue in Model file path Vendor/CategoryImportExport/Model/Export/Category.php here need to categories data and after generate csv but I can't getting that details.

I have added Entity Type catalog_category in etc/export.xml for Category and it's displaying fine in Entity Type Dropdown.

File path: magento/app/code/Vendor/CategoryImportExport/etc/export.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_ImportExport:etc/export.xsd">
    <entity name="catalog_category" label="Category" model="Vendor\CategoryImportExport\Model\Export\Category" entityAttributeFilterType="catalog_category"/>
    <fileFormat name="csv" label="CSV" model="Magento\ImportExport\Model\Export\Adapter\Csv" />

File path: magento/app/code/Vendor/CategoryImportExport/Model/Export/Category.php

class Category extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
    public function export()
        //Execution time may be very long

        $writer = $this->getWriter();
        $page = 0;
        while (true) {
            $entityCollection = $this->_getEntityCollection(true);
            $entityCollection->setOrder('entity_id', 'asc');
            $this->paginateCollection($page, $this->getItemsPerPage());
            if ($entityCollection->count() == 0) {
            $exportData = $this->getExportData();
            if ($page == 1) {
            foreach ($exportData as $dataRow) {
            if ($entityCollection->getCurPage() >= $entityCollection->getLastPageNumber()) {
        return $writer->getContents();

Any have idea how to import export Categories in csv then let me know.

Any help would be appreciated. Thanks.

Your Answer

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

Browse other questions tagged or ask your own question.