I have to import a 3rd party catalog into Magento 2.3. I need to recreate in Magento the category tree with the same category_id in the original tree because I need it when I update inventory. How can I do it? Exist an extension? Can I do it directly on the DB? Below you can see an example of the category tree I need to recreate. Any suggestion will be appreciated!! enter image description here


The category id on Magento is an integer number, so you won't be able to use something as A014. If all categories begin with "A" and the rest of the id is a number, you could just ignore the A and insert the categories using the integer part of your category id.

Another possible solution, which in my opinion is the correct (and easiest) way to implement what you need, is to add a new attribute to the category. In order to do that, you need to create a new Module and add the following install script:

//File: Vendor/YourModule/Setup/InstallData.php

use Magento\Framework\Setup\{

use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;

class InstallData implements InstallDataInterface
    private $eavSetupFactory;

    public function __construct(EavSetupFactory $eavSetupFactory) {
        $this->eavSetupFactory = $eavSetupFactory;

    public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
        $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
        $eavSetup->addAttribute(\Magento\Catalog\Model\Category::ENTITY, 'attribute_id', [
            'type'     => 'varchar',
            'label'    => 'Category Code',
            'input'    => 'text',
            'visible'  => true,
            'default'  => null,
            'required' => false,
            'global'   => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
            'group'    => 'Display Settings',

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.