I cannot find any information regarding category import in magento 2. Installing the merchant-beta version I found: advanced pricing, products and customer import options, but nothing for categories.

I tried ubertheme data migration tool but it seems is not supported to migrate thousands of categories. any reference or help appreciated.


I tried the magento data migration official release recommended by @Mage2.PRO but the following problem appear when installing.

enter image description here

  • 1
    The tool is compatible with Magento 2 Beta (the version you have specified in your question's tags) but is not updated to Magento 2 Release Candidate yet. So you should use Magento 2 Beta with the tool.
    – Mage2.PRO
    Nov 15 '15 at 19:50

See the official data migration tool: https://github.com/magento/data-migration-tool-ce


Magento 2 does not have separate import tool for categories, so you can't create category structure first. Although, you can create categories via product import. If you have full category path for products in the import file and such category does not exist in Magento 2, it will be created.


Please use the following code for category import.

 foreach ( $arrResult as $import_category ) {

    try {

        $enabled = ( strtolower( $import_category[16] ) == 'true' ) ? 1 : 0;
        $parentId = ( $import_category[1] == 0 )? '2' : $list[$import_category[1]];            

        $url = strtolower($import_category[2]);
        $cleanurl = trim(preg_replace('/ +/', '', preg_replace('/[^A-Za-z0-9 ]/', '', urldecode(html_entity_decode(strip_tags($url))))));
        $categoryFactory = $objectManager->get('\Magento\Catalog\Model\CategoryFactory');
        /// Add a new sub category under root category
        $category = $categoryFactory->create();
        $category->setIsActive( $enabled );
        $category->setData('description', strip_tags($import_category[11]));
        $mediaAttribute = array ('image', 'small_image', 'thumbnail');
        $category->setImage( $import_category[6], $mediaAttribute, true, false);// Path pub/meida/catalog/category/
        $rootCat = $objectManager->get('Magento\Catalog\Model\Category')->load($parentId);
        $list[$import_category[0]] = $category->getId();
        echo 'Category ' . $category->getName() . ' ' . $category->getId() . ' imported successfully' . PHP_EOL;
    catch (Exception $e) 
        echo 'Something failed for category ' . $import_category[2] . PHP_EOL;

Click here for detailed explanation . http://www.pearlbells.co.uk/import-magento-2-categories-programmatically/

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.