How to reset the category ID's count # for Magento 2.x?Linking back to specific current categories from the product view pageDisplay more than one category in the same CMS PageChange category ID'sHow to Move Products, Attributes, Images, and Customers From One Magento Installation to AnotherChanging category ID's / Resetting Magento ID CountMagento query doesn't filter on category_idHow to implement multiple category filter in Magento 2 layered navigationmagmi . remove skus from their existing category in website #1 but leave them in website #22.2.3 : Are there situations when @magentoDbIsolation cannot be used in integration tests?Magento Flat Category Table contains incorrect data (even after reindexing)

Who will lead the country until there is a new Tory leader?

What was the idiom for something that we take without a doubt?

Can I tell a prospective employee that everyone in the team is leaving?

Externally monitoring CPU/SSD activity without software access

Did 20% of US soldiers in Vietnam use heroin, 95% of whom quit afterwards?

Is it rude to call a professor by their last name with no prefix in a non-academic setting?

Should one buy new hardware after a system compromise?

Which melee weapons have the Two-Handed property, but lack Heavy and Special?

Inconsistent results from Wolfram Could

Looking for a soft substance that doesn't dissolve underwater

How did these characters "suit up" so quickly?

Is it true that cut time means "play twice as fast as written"?

Is Jon Snow the last of his House?

Where is the logic in castrating fighters?

What to do when you've set the wrong ISO for your film?

Why would Ryanair allow me to book this journey through a third party, but not through their own website?

Count Even Digits In Number

Are these reasonable traits for someone with autism?

Plot and know intersection points of multiple lines/functions

Make 24 using exactly three 3s

Installed Tankless Water Heater - Internet loss when active

Should I disclose a colleague's illness (that I should not know) when others badmouth him

Python program to take in two strings and print the larger string

The art of clickbait captions



How to reset the category ID's count # for Magento 2.x?


Linking back to specific current categories from the product view pageDisplay more than one category in the same CMS PageChange category ID'sHow to Move Products, Attributes, Images, and Customers From One Magento Installation to AnotherChanging category ID's / Resetting Magento ID CountMagento query doesn't filter on category_idHow to implement multiple category filter in Magento 2 layered navigationmagmi . remove skus from their existing category in website #1 but leave them in website #22.2.3 : Are there situations when @magentoDbIsolation cannot be used in integration tests?Magento Flat Category Table contains incorrect data (even after reindexing)






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I'm using a 3rd party plugin to setup our production website in a test/dev environment. It allows export/import of the categories, excluding the Category ID's (which are automatically generated).
As a test, we created a full list of categories and a single product. Exported both, wiped both the product and categories, and the import works. Except that the Category ID's are being added incrementally (instead of being "reset" when I delete the categories). This makes sense from a Db perspective, so I'm assuming that the Category ID # is being incrementally counted from some Db count location.



Does anybody know where this count is coming from, and where I can reset it in Magento 2.1 ? (this is just for testing purposes).



Thanks in advance.










share|improve this question






























    0















    I'm using a 3rd party plugin to setup our production website in a test/dev environment. It allows export/import of the categories, excluding the Category ID's (which are automatically generated).
    As a test, we created a full list of categories and a single product. Exported both, wiped both the product and categories, and the import works. Except that the Category ID's are being added incrementally (instead of being "reset" when I delete the categories). This makes sense from a Db perspective, so I'm assuming that the Category ID # is being incrementally counted from some Db count location.



    Does anybody know where this count is coming from, and where I can reset it in Magento 2.1 ? (this is just for testing purposes).



    Thanks in advance.










    share|improve this question


























      0












      0








      0








      I'm using a 3rd party plugin to setup our production website in a test/dev environment. It allows export/import of the categories, excluding the Category ID's (which are automatically generated).
      As a test, we created a full list of categories and a single product. Exported both, wiped both the product and categories, and the import works. Except that the Category ID's are being added incrementally (instead of being "reset" when I delete the categories). This makes sense from a Db perspective, so I'm assuming that the Category ID # is being incrementally counted from some Db count location.



      Does anybody know where this count is coming from, and where I can reset it in Magento 2.1 ? (this is just for testing purposes).



      Thanks in advance.










      share|improve this question
















      I'm using a 3rd party plugin to setup our production website in a test/dev environment. It allows export/import of the categories, excluding the Category ID's (which are automatically generated).
      As a test, we created a full list of categories and a single product. Exported both, wiped both the product and categories, and the import works. Except that the Category ID's are being added incrementally (instead of being "reset" when I delete the categories). This makes sense from a Db perspective, so I'm assuming that the Category ID # is being incrementally counted from some Db count location.



      Does anybody know where this count is coming from, and where I can reset it in Magento 2.1 ? (this is just for testing purposes).



      Thanks in advance.







      magento2 category database






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 23 '16 at 9:14









      Kappa

      20919




      20919










      asked Jul 27 '16 at 15:39









      SquishySquishy

      65




      65




















          2 Answers
          2






          active

          oldest

          votes


















          0














          If you delete categories from admin panel, newly created categories will be having an id based on last created category id(irrespective of whether it's present or deleted). You need to truncate these categories using following sql queries which will reset the ids. Take db backup before executing it.



           SET FOREIGN_KEY_CHECKS = 0;

          TRUNCATE TABLE `catalog_category_entity`;
          TRUNCATE TABLE `catalog_category_entity_datetime`;
          TRUNCATE TABLE `catalog_category_entity_decimal`;
          TRUNCATE TABLE `catalog_category_entity_int`;
          TRUNCATE TABLE `catalog_category_entity_text`;
          TRUNCATE TABLE `catalog_category_entity_varchar`;
          TRUNCATE TABLE `catalog_category_product`;
          TRUNCATE TABLE `catalog_category_product_index`;

          INSERT INTO `catalog_category_entity` (`entity_id`, `attribute_set_id`, `parent_id`, `created_at`, `updated_at`, `path`, `position`, `level`, `children_count`) VALUES ('1', '0', '0', '2016-06-23 00:00:00', '2016-06-23 00:00:00', '1', '0', '0', '1'), ('2', '3', '1', '2016-06-23 00:00:00', '2016-06-23 00:00:00', '1/2', '1', '1', '0');
          INSERT INTO `catalog_category_entity_datetime` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ('1', '58', '0', '1', NULL), (2, 58, 0, 2, NULL);
          INSERT INTO `catalog_category_entity_decimal` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES
          (1, 69, 0, 2, NULL);
          INSERT INTO `catalog_category_entity_int` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ('1', '66', '0', '1', '1'), (2, 43, 0, 2, 1), (3, 50, 0, 2, NULL), (4, 51, 0, 2, 1), (5, 66, 0, 2, 1), (6, 68, 0, 2, 0);
          INSERT INTO `catalog_category_entity_text` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ('1', '64', '0', '1', NULL), (2, 64, 0, 2, NULL), (3, 44, 0, 2, NULL), (4, 47, 0, 2, NULL), (5, 48, 0, 2, NULL), (6, 61, 0, 2, NULL);
          INSERT INTO `catalog_category_entity_varchar` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ('1', '42', '0', '1', 'Root Catalog');
          INSERT INTO `catalog_category_entity_varchar` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES (2, 42, 0, 2, 'Default Category'), (3, 46, 0, 2, NULL), (4, 49, 0, 2, 'PRODUCTS'), (5, 57, 0, 2, NULL), (6, 60, 0, 2, NULL), (7, 65, 0, 2, NULL), (8, 113, 0, 2, 'default-category'), (9, 114, 0, 2, NULL), (10, 143, 0, 2, NULL), (11, 145, 0, 2, NULL), (12, 147, 0, 2, NULL);

          SET FOREIGN_KEY_CHECKS = 1;





          share|improve this answer























          • Not working in my case Magento 2.2.4 Getting the following: 1701 - Cannot truncate a table referenced in a foreign key constraint (test_db.catalog_category_entity_decimal, CONSTRAINT CAT_CTGR_ENTT_DEC_ENTT_ID_CAT_CTGR_ENTT_ENTT_ID FOREIGN KEY (entity_id) REFERENCES test_db.catalog_category_entity)

            – user2478262
            Jul 11 '18 at 11:11












          • Have you used SET FOREIGN_KEY_CHECKS = 0; before executing truncate queries?

            – amitshree
            Jul 11 '18 at 11:48


















          0














          If you have phpMyAdmin then you can do by going to table and clicking on Operations. After that you see a AUTO_INCREMENT which in my case is 42. You can reset it to 1 and it should solve your problem.
          enter image description here



          If you have command line access only then you can run the below mysql query:



          ALTER TABLE `catalog_category_entity` AUTO_INCREMENT=1





          share|improve this answer























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "479"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f127749%2fhow-to-reset-the-category-ids-count-for-magento-2-x%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            If you delete categories from admin panel, newly created categories will be having an id based on last created category id(irrespective of whether it's present or deleted). You need to truncate these categories using following sql queries which will reset the ids. Take db backup before executing it.



             SET FOREIGN_KEY_CHECKS = 0;

            TRUNCATE TABLE `catalog_category_entity`;
            TRUNCATE TABLE `catalog_category_entity_datetime`;
            TRUNCATE TABLE `catalog_category_entity_decimal`;
            TRUNCATE TABLE `catalog_category_entity_int`;
            TRUNCATE TABLE `catalog_category_entity_text`;
            TRUNCATE TABLE `catalog_category_entity_varchar`;
            TRUNCATE TABLE `catalog_category_product`;
            TRUNCATE TABLE `catalog_category_product_index`;

            INSERT INTO `catalog_category_entity` (`entity_id`, `attribute_set_id`, `parent_id`, `created_at`, `updated_at`, `path`, `position`, `level`, `children_count`) VALUES ('1', '0', '0', '2016-06-23 00:00:00', '2016-06-23 00:00:00', '1', '0', '0', '1'), ('2', '3', '1', '2016-06-23 00:00:00', '2016-06-23 00:00:00', '1/2', '1', '1', '0');
            INSERT INTO `catalog_category_entity_datetime` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ('1', '58', '0', '1', NULL), (2, 58, 0, 2, NULL);
            INSERT INTO `catalog_category_entity_decimal` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES
            (1, 69, 0, 2, NULL);
            INSERT INTO `catalog_category_entity_int` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ('1', '66', '0', '1', '1'), (2, 43, 0, 2, 1), (3, 50, 0, 2, NULL), (4, 51, 0, 2, 1), (5, 66, 0, 2, 1), (6, 68, 0, 2, 0);
            INSERT INTO `catalog_category_entity_text` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ('1', '64', '0', '1', NULL), (2, 64, 0, 2, NULL), (3, 44, 0, 2, NULL), (4, 47, 0, 2, NULL), (5, 48, 0, 2, NULL), (6, 61, 0, 2, NULL);
            INSERT INTO `catalog_category_entity_varchar` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ('1', '42', '0', '1', 'Root Catalog');
            INSERT INTO `catalog_category_entity_varchar` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES (2, 42, 0, 2, 'Default Category'), (3, 46, 0, 2, NULL), (4, 49, 0, 2, 'PRODUCTS'), (5, 57, 0, 2, NULL), (6, 60, 0, 2, NULL), (7, 65, 0, 2, NULL), (8, 113, 0, 2, 'default-category'), (9, 114, 0, 2, NULL), (10, 143, 0, 2, NULL), (11, 145, 0, 2, NULL), (12, 147, 0, 2, NULL);

            SET FOREIGN_KEY_CHECKS = 1;





            share|improve this answer























            • Not working in my case Magento 2.2.4 Getting the following: 1701 - Cannot truncate a table referenced in a foreign key constraint (test_db.catalog_category_entity_decimal, CONSTRAINT CAT_CTGR_ENTT_DEC_ENTT_ID_CAT_CTGR_ENTT_ENTT_ID FOREIGN KEY (entity_id) REFERENCES test_db.catalog_category_entity)

              – user2478262
              Jul 11 '18 at 11:11












            • Have you used SET FOREIGN_KEY_CHECKS = 0; before executing truncate queries?

              – amitshree
              Jul 11 '18 at 11:48















            0














            If you delete categories from admin panel, newly created categories will be having an id based on last created category id(irrespective of whether it's present or deleted). You need to truncate these categories using following sql queries which will reset the ids. Take db backup before executing it.



             SET FOREIGN_KEY_CHECKS = 0;

            TRUNCATE TABLE `catalog_category_entity`;
            TRUNCATE TABLE `catalog_category_entity_datetime`;
            TRUNCATE TABLE `catalog_category_entity_decimal`;
            TRUNCATE TABLE `catalog_category_entity_int`;
            TRUNCATE TABLE `catalog_category_entity_text`;
            TRUNCATE TABLE `catalog_category_entity_varchar`;
            TRUNCATE TABLE `catalog_category_product`;
            TRUNCATE TABLE `catalog_category_product_index`;

            INSERT INTO `catalog_category_entity` (`entity_id`, `attribute_set_id`, `parent_id`, `created_at`, `updated_at`, `path`, `position`, `level`, `children_count`) VALUES ('1', '0', '0', '2016-06-23 00:00:00', '2016-06-23 00:00:00', '1', '0', '0', '1'), ('2', '3', '1', '2016-06-23 00:00:00', '2016-06-23 00:00:00', '1/2', '1', '1', '0');
            INSERT INTO `catalog_category_entity_datetime` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ('1', '58', '0', '1', NULL), (2, 58, 0, 2, NULL);
            INSERT INTO `catalog_category_entity_decimal` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES
            (1, 69, 0, 2, NULL);
            INSERT INTO `catalog_category_entity_int` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ('1', '66', '0', '1', '1'), (2, 43, 0, 2, 1), (3, 50, 0, 2, NULL), (4, 51, 0, 2, 1), (5, 66, 0, 2, 1), (6, 68, 0, 2, 0);
            INSERT INTO `catalog_category_entity_text` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ('1', '64', '0', '1', NULL), (2, 64, 0, 2, NULL), (3, 44, 0, 2, NULL), (4, 47, 0, 2, NULL), (5, 48, 0, 2, NULL), (6, 61, 0, 2, NULL);
            INSERT INTO `catalog_category_entity_varchar` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ('1', '42', '0', '1', 'Root Catalog');
            INSERT INTO `catalog_category_entity_varchar` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES (2, 42, 0, 2, 'Default Category'), (3, 46, 0, 2, NULL), (4, 49, 0, 2, 'PRODUCTS'), (5, 57, 0, 2, NULL), (6, 60, 0, 2, NULL), (7, 65, 0, 2, NULL), (8, 113, 0, 2, 'default-category'), (9, 114, 0, 2, NULL), (10, 143, 0, 2, NULL), (11, 145, 0, 2, NULL), (12, 147, 0, 2, NULL);

            SET FOREIGN_KEY_CHECKS = 1;





            share|improve this answer























            • Not working in my case Magento 2.2.4 Getting the following: 1701 - Cannot truncate a table referenced in a foreign key constraint (test_db.catalog_category_entity_decimal, CONSTRAINT CAT_CTGR_ENTT_DEC_ENTT_ID_CAT_CTGR_ENTT_ENTT_ID FOREIGN KEY (entity_id) REFERENCES test_db.catalog_category_entity)

              – user2478262
              Jul 11 '18 at 11:11












            • Have you used SET FOREIGN_KEY_CHECKS = 0; before executing truncate queries?

              – amitshree
              Jul 11 '18 at 11:48













            0












            0








            0







            If you delete categories from admin panel, newly created categories will be having an id based on last created category id(irrespective of whether it's present or deleted). You need to truncate these categories using following sql queries which will reset the ids. Take db backup before executing it.



             SET FOREIGN_KEY_CHECKS = 0;

            TRUNCATE TABLE `catalog_category_entity`;
            TRUNCATE TABLE `catalog_category_entity_datetime`;
            TRUNCATE TABLE `catalog_category_entity_decimal`;
            TRUNCATE TABLE `catalog_category_entity_int`;
            TRUNCATE TABLE `catalog_category_entity_text`;
            TRUNCATE TABLE `catalog_category_entity_varchar`;
            TRUNCATE TABLE `catalog_category_product`;
            TRUNCATE TABLE `catalog_category_product_index`;

            INSERT INTO `catalog_category_entity` (`entity_id`, `attribute_set_id`, `parent_id`, `created_at`, `updated_at`, `path`, `position`, `level`, `children_count`) VALUES ('1', '0', '0', '2016-06-23 00:00:00', '2016-06-23 00:00:00', '1', '0', '0', '1'), ('2', '3', '1', '2016-06-23 00:00:00', '2016-06-23 00:00:00', '1/2', '1', '1', '0');
            INSERT INTO `catalog_category_entity_datetime` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ('1', '58', '0', '1', NULL), (2, 58, 0, 2, NULL);
            INSERT INTO `catalog_category_entity_decimal` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES
            (1, 69, 0, 2, NULL);
            INSERT INTO `catalog_category_entity_int` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ('1', '66', '0', '1', '1'), (2, 43, 0, 2, 1), (3, 50, 0, 2, NULL), (4, 51, 0, 2, 1), (5, 66, 0, 2, 1), (6, 68, 0, 2, 0);
            INSERT INTO `catalog_category_entity_text` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ('1', '64', '0', '1', NULL), (2, 64, 0, 2, NULL), (3, 44, 0, 2, NULL), (4, 47, 0, 2, NULL), (5, 48, 0, 2, NULL), (6, 61, 0, 2, NULL);
            INSERT INTO `catalog_category_entity_varchar` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ('1', '42', '0', '1', 'Root Catalog');
            INSERT INTO `catalog_category_entity_varchar` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES (2, 42, 0, 2, 'Default Category'), (3, 46, 0, 2, NULL), (4, 49, 0, 2, 'PRODUCTS'), (5, 57, 0, 2, NULL), (6, 60, 0, 2, NULL), (7, 65, 0, 2, NULL), (8, 113, 0, 2, 'default-category'), (9, 114, 0, 2, NULL), (10, 143, 0, 2, NULL), (11, 145, 0, 2, NULL), (12, 147, 0, 2, NULL);

            SET FOREIGN_KEY_CHECKS = 1;





            share|improve this answer













            If you delete categories from admin panel, newly created categories will be having an id based on last created category id(irrespective of whether it's present or deleted). You need to truncate these categories using following sql queries which will reset the ids. Take db backup before executing it.



             SET FOREIGN_KEY_CHECKS = 0;

            TRUNCATE TABLE `catalog_category_entity`;
            TRUNCATE TABLE `catalog_category_entity_datetime`;
            TRUNCATE TABLE `catalog_category_entity_decimal`;
            TRUNCATE TABLE `catalog_category_entity_int`;
            TRUNCATE TABLE `catalog_category_entity_text`;
            TRUNCATE TABLE `catalog_category_entity_varchar`;
            TRUNCATE TABLE `catalog_category_product`;
            TRUNCATE TABLE `catalog_category_product_index`;

            INSERT INTO `catalog_category_entity` (`entity_id`, `attribute_set_id`, `parent_id`, `created_at`, `updated_at`, `path`, `position`, `level`, `children_count`) VALUES ('1', '0', '0', '2016-06-23 00:00:00', '2016-06-23 00:00:00', '1', '0', '0', '1'), ('2', '3', '1', '2016-06-23 00:00:00', '2016-06-23 00:00:00', '1/2', '1', '1', '0');
            INSERT INTO `catalog_category_entity_datetime` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ('1', '58', '0', '1', NULL), (2, 58, 0, 2, NULL);
            INSERT INTO `catalog_category_entity_decimal` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES
            (1, 69, 0, 2, NULL);
            INSERT INTO `catalog_category_entity_int` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ('1', '66', '0', '1', '1'), (2, 43, 0, 2, 1), (3, 50, 0, 2, NULL), (4, 51, 0, 2, 1), (5, 66, 0, 2, 1), (6, 68, 0, 2, 0);
            INSERT INTO `catalog_category_entity_text` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ('1', '64', '0', '1', NULL), (2, 64, 0, 2, NULL), (3, 44, 0, 2, NULL), (4, 47, 0, 2, NULL), (5, 48, 0, 2, NULL), (6, 61, 0, 2, NULL);
            INSERT INTO `catalog_category_entity_varchar` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ('1', '42', '0', '1', 'Root Catalog');
            INSERT INTO `catalog_category_entity_varchar` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES (2, 42, 0, 2, 'Default Category'), (3, 46, 0, 2, NULL), (4, 49, 0, 2, 'PRODUCTS'), (5, 57, 0, 2, NULL), (6, 60, 0, 2, NULL), (7, 65, 0, 2, NULL), (8, 113, 0, 2, 'default-category'), (9, 114, 0, 2, NULL), (10, 143, 0, 2, NULL), (11, 145, 0, 2, NULL), (12, 147, 0, 2, NULL);

            SET FOREIGN_KEY_CHECKS = 1;






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jul 27 '16 at 16:47









            amitshreeamitshree

            3,317103985




            3,317103985












            • Not working in my case Magento 2.2.4 Getting the following: 1701 - Cannot truncate a table referenced in a foreign key constraint (test_db.catalog_category_entity_decimal, CONSTRAINT CAT_CTGR_ENTT_DEC_ENTT_ID_CAT_CTGR_ENTT_ENTT_ID FOREIGN KEY (entity_id) REFERENCES test_db.catalog_category_entity)

              – user2478262
              Jul 11 '18 at 11:11












            • Have you used SET FOREIGN_KEY_CHECKS = 0; before executing truncate queries?

              – amitshree
              Jul 11 '18 at 11:48

















            • Not working in my case Magento 2.2.4 Getting the following: 1701 - Cannot truncate a table referenced in a foreign key constraint (test_db.catalog_category_entity_decimal, CONSTRAINT CAT_CTGR_ENTT_DEC_ENTT_ID_CAT_CTGR_ENTT_ENTT_ID FOREIGN KEY (entity_id) REFERENCES test_db.catalog_category_entity)

              – user2478262
              Jul 11 '18 at 11:11












            • Have you used SET FOREIGN_KEY_CHECKS = 0; before executing truncate queries?

              – amitshree
              Jul 11 '18 at 11:48
















            Not working in my case Magento 2.2.4 Getting the following: 1701 - Cannot truncate a table referenced in a foreign key constraint (test_db.catalog_category_entity_decimal, CONSTRAINT CAT_CTGR_ENTT_DEC_ENTT_ID_CAT_CTGR_ENTT_ENTT_ID FOREIGN KEY (entity_id) REFERENCES test_db.catalog_category_entity)

            – user2478262
            Jul 11 '18 at 11:11






            Not working in my case Magento 2.2.4 Getting the following: 1701 - Cannot truncate a table referenced in a foreign key constraint (test_db.catalog_category_entity_decimal, CONSTRAINT CAT_CTGR_ENTT_DEC_ENTT_ID_CAT_CTGR_ENTT_ENTT_ID FOREIGN KEY (entity_id) REFERENCES test_db.catalog_category_entity)

            – user2478262
            Jul 11 '18 at 11:11














            Have you used SET FOREIGN_KEY_CHECKS = 0; before executing truncate queries?

            – amitshree
            Jul 11 '18 at 11:48





            Have you used SET FOREIGN_KEY_CHECKS = 0; before executing truncate queries?

            – amitshree
            Jul 11 '18 at 11:48













            0














            If you have phpMyAdmin then you can do by going to table and clicking on Operations. After that you see a AUTO_INCREMENT which in my case is 42. You can reset it to 1 and it should solve your problem.
            enter image description here



            If you have command line access only then you can run the below mysql query:



            ALTER TABLE `catalog_category_entity` AUTO_INCREMENT=1





            share|improve this answer



























              0














              If you have phpMyAdmin then you can do by going to table and clicking on Operations. After that you see a AUTO_INCREMENT which in my case is 42. You can reset it to 1 and it should solve your problem.
              enter image description here



              If you have command line access only then you can run the below mysql query:



              ALTER TABLE `catalog_category_entity` AUTO_INCREMENT=1





              share|improve this answer

























                0












                0








                0







                If you have phpMyAdmin then you can do by going to table and clicking on Operations. After that you see a AUTO_INCREMENT which in my case is 42. You can reset it to 1 and it should solve your problem.
                enter image description here



                If you have command line access only then you can run the below mysql query:



                ALTER TABLE `catalog_category_entity` AUTO_INCREMENT=1





                share|improve this answer













                If you have phpMyAdmin then you can do by going to table and clicking on Operations. After that you see a AUTO_INCREMENT which in my case is 42. You can reset it to 1 and it should solve your problem.
                enter image description here



                If you have command line access only then you can run the below mysql query:



                ALTER TABLE `catalog_category_entity` AUTO_INCREMENT=1






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered May 20 at 3:35









                Arif AhmadArif Ahmad

                612




                612



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f127749%2fhow-to-reset-the-category-ids-count-for-magento-2-x%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

                    Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                    Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form