Magento2: Magento 2.1.8: Unable to create subcategory

Created on 25 Sep 2017  路  7Comments  路  Source: magento/magento2

Preconditions

  1. Magento 2.1.8, 2.1.9

Steps to reproduce

  1. Attempt to create new subcategory inside the "Default Category" (or any of its subcategories)

Actual result

  1. Error occurs
main.CRITICAL: InvalidArgumentException: indexMethod must be one of in /home/site/websites/www.mysite.com/htdocs/vendor/magento/framework/DB/TemporaryTableService.php:104

Expected result

  1. Subcategory is created.

Additional Information

I am able to create new root categories (and sub-categories of those), but if I try to create a new subcategory in "Default Category" (or any of its subcategories), I receive the following exception:

main.CRITICAL: InvalidArgumentException: indexMethod must be one of in /home/site/websites/www.mysite.com/htdocs/vendor/magento/framework/DB/TemporaryTableService.php:104

It may or may not be related, but the catalog_url_rewrite_product_category table is completely empty.

I have tried reindexing, clearing caches, compiling, etc. All to to no avail.

The same error is also reported if I try to save changes to an existing category, or move a category.

Cannot Reproduce Clear Description Format is valid

Most helpful comment

In my case, the problem was caused by a faulty upgrade from 2.1.7 to 2.1.9. I needed to overwrite the app/etc/di.xml file manually with the file from the official repo. During the composer upgrade, app/etc/di.xml was not overwritten correctly. The new di.xml file contains these new additions, which are needed to make the code in magento/framework/DB/TemporaryTableService.php work:

    <type name="Magento\Framework\DB\TemporaryTableService">
        <arguments>
            <argument name="allowedIndexMethods" xsi:type="array">
                <item name="HASH" xsi:type="string">HASH</item>
                <item name="BTREE" xsi:type="string">BTREE</item>
            </argument>
            <argument name="allowedEngines" xsi:type="array">
                <item name="INNODB" xsi:type="string">INNODB</item>
                <item name="MEMORY" xsi:type="string">MEMORY</item>
                <item name="MYISAM" xsi:type="string">MYISAM</item>
            </argument>
        </arguments>
    </type>

If your di.xml file is not up to date, you'll have a bunch of errors while trying to save categories, and probably many other issues.

All 7 comments

Hi @Geater
We have updated your issue report to follow reporting guidelines and will verify the problem according to it.
Please let us know if it is correct.
Thank you.

@Geater, thank you for your report.
We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue.
We tested the issue on 2.3.0, 2.2.0, 2.1.9

It's vendor/magento/module-catalog-url-rewrite/Model/Category/CurrentUrlRewritesRegenerator.php and vendor/magento/module-catalog-url-rewrite/Model/Product/CurrentUrlRewritesRegenerator.php getting the wrong entity type info (ProductUrlRewriteGenerator::ENTITY_TYPE returns 'product' instead of 4, CategoryUrlRewriteGenerator::ENTITY_TYPE is 'category' instead of 3)

@ShoobyBan If that is indeed the problem, do you know the best way to fix it?

the catalog_url_rewrite_product_category table is completely empty.

It should not be empty in case you have some visible on storefront product in some visible on storefront category.

In my case, the problem was caused by a faulty upgrade from 2.1.7 to 2.1.9. I needed to overwrite the app/etc/di.xml file manually with the file from the official repo. During the composer upgrade, app/etc/di.xml was not overwritten correctly. The new di.xml file contains these new additions, which are needed to make the code in magento/framework/DB/TemporaryTableService.php work:

    <type name="Magento\Framework\DB\TemporaryTableService">
        <arguments>
            <argument name="allowedIndexMethods" xsi:type="array">
                <item name="HASH" xsi:type="string">HASH</item>
                <item name="BTREE" xsi:type="string">BTREE</item>
            </argument>
            <argument name="allowedEngines" xsi:type="array">
                <item name="INNODB" xsi:type="string">INNODB</item>
                <item name="MEMORY" xsi:type="string">MEMORY</item>
                <item name="MYISAM" xsi:type="string">MYISAM</item>
            </argument>
        </arguments>
    </type>

If your di.xml file is not up to date, you'll have a bunch of errors while trying to save categories, and probably many other issues.

@dakzilla That's absolutely what the issue was. Adding those lines and recompiling sorted everything. Thanks so much!

Was this page helpful?
0 / 5 - 0 ratings