Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find category with id / We are already refreshing the category url key's, just have a little patience 馃檪 #30

Closed
Nuranto opened this issue Oct 19, 2021 · 10 comments

Comments

@Nuranto
Copy link

Nuranto commented Oct 19, 2021

On first try of this command ( catalog:category:integrity:urlkey )

I got this error : Can't find category with id

And if try to launch again : We are already refreshing the category url key's, just have a little patience 馃檪

An unexpected exception occured: 'Can't find category with id: '36764''
#0 /var/www/html/vendor/baldwin/magento2-module-url-data-integrity-checker/Checker/Catalog/Category/UrlPath.php(117): Baldwin\UrlDataIntegrityChecker\Checker\Catalog\Category\UrlPath->fetchAllCategoriesWithUrlPathCalculatedByUrlKey()
#1 /var/www/html/vendor/baldwin/magento2-module-url-data-integrity-checker/Checker/Catalog/Category/UrlKey/DuplicateUrlKey.php(87): Baldwin\UrlDataIntegrityChecker\Checker\Catalog\Category\UrlPath->getCalculatedUrlPathForCategory(Object(Magento\Catalog\Model\Category\Interceptor), 1)
#2 /var/www/html/vendor/baldwin/magento2-module-url-data-integrity-checker/Checker/Catalog/Category/UrlKey/DuplicateUrlKey.php(48): Baldwin\UrlDataIntegrityChecker\Checker\Catalog\Category\UrlKey\DuplicateUrlKey->getCategoryUrlPathsByStoreId(1)
#3 /var/www/html/vendor/baldwin/magento2-module-url-data-integrity-checker/Checker/Catalog/Category/UrlKey/DuplicateUrlKey.php(34): Baldwin\UrlDataIntegrityChecker\Checker\Catalog\Category\UrlKey\DuplicateUrlKey->checkForDuplicatedUrlKeyAttributeValues()
#4 /var/www/html/vendor/baldwin/magento2-module-url-data-integrity-checker/Checker/Catalog/Category/UrlKey.php(32): Baldwin\UrlDataIntegrityChecker\Checker\Catalog\Category\UrlKey\DuplicateUrlKey->execute()
#5 /var/www/html/vendor/baldwin/magento2-module-url-data-integrity-checker/Updater/Catalog/Category/UrlKey.php(47): Baldwin\UrlDataIntegrityChecker\Checker\Catalog\Category\UrlKey->execute()
#6 /var/www/html/vendor/baldwin/magento2-module-url-data-integrity-checker/Console/Command/CheckCategoryUrlKeys.php(64): Baldwin\UrlDataIntegrityChecker\Updater\Catalog\Category\UrlKey->refresh('CLI')
#7 /var/www/html/vendor/symfony/console/Command/Command.php(255): Baldwin\UrlDataIntegrityChecker\Console\Command\CheckCategoryUrlKeys->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Baldwin\UrlDataIntegrityChecker\Console\Command\CheckCategoryUrlKeys\Interceptor->___callParent('run', Array)
#10 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Baldwin\UrlDataIntegrityChecker\Console\Command\CheckCategoryUrlKeys\Interceptor->Magento\Framework\Interception\{closure}(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /var/www/html/generated/code/Baldwin/UrlDataIntegrityChecker/Console/Command/CheckCategoryUrlKeys/Interceptor.php(23): Baldwin\UrlDataIntegrityChecker\Console\Command\CheckCategoryUrlKeys\Interceptor->___callPlugins('run', Array, Array)
#12 /var/www/html/vendor/symfony/console/Application.php(1009): Baldwin\UrlDataIntegrityChecker\Console\Command\CheckCategoryUrlKeys\Interceptor->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/html/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand(Object(Baldwin\UrlDataIntegrityChecker\Console\Command\CheckCategoryUrlKeys\Interceptor), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/html/vendor/magento/framework/Console/Cli.php(115): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/html/vendor/symfony/console/Application.php(149): Magento\Framework\Console\Cli->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /var/www/html/bin/magento(23): Symfony\Component\Console\Application->run()
#17 {main}
root@prod-m2-fo-6959cb5f58-p6bvb:/var/www/html# ./magento catalog:category:integrity:urlkey
An unexpected exception occured: 'We are already refreshing the category url key's, just have a little patience 馃檪'
#0 /var/www/html/vendor/baldwin/magento2-module-url-data-integrity-checker/Console/Command/CheckCategoryUrlKeys.php(64): Baldwin\UrlDataIntegrityChecker\Updater\Catalog\Category\UrlKey->refresh('CLI')
#1 /var/www/html/vendor/symfony/console/Command/Command.php(255): Baldwin\UrlDataIntegrityChecker\Console\Command\CheckCategoryUrlKeys->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Baldwin\UrlDataIntegrityChecker\Console\Command\CheckCategoryUrlKeys\Interceptor->___callParent('run', Array)
#4 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Baldwin\UrlDataIntegrityChecker\Console\Command\CheckCategoryUrlKeys\Interceptor->Magento\Framework\Interception\{closure}(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /var/www/html/generated/code/Baldwin/UrlDataIntegrityChecker/Console/Command/CheckCategoryUrlKeys/Interceptor.php(23): Baldwin\UrlDataIntegrityChecker\Console\Command\CheckCategoryUrlKeys\Interceptor->___callPlugins('run', Array, Array)
#6 /var/www/html/vendor/symfony/console/Application.php(1009): Baldwin\UrlDataIntegrityChecker\Console\Command\CheckCategoryUrlKeys\Interceptor->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /var/www/html/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand(Object(Baldwin\UrlDataIntegrityChecker\Console\Command\CheckCategoryUrlKeys\Interceptor), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /var/www/html/vendor/magento/framework/Console/Cli.php(115): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /var/www/html/vendor/symfony/console/Application.php(149): Magento\Framework\Console\Cli->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /var/www/html/bin/magento(23): Symfony\Component\Console\Application->run()
#11 {main}
@hostep
Copy link
Member

hostep commented Oct 19, 2021

Thanks for the report @Nuranto

Let's start with the second problem.
You can pass an extra --force flag in the command to skip that check.
However, I believe you found a bug here, we should probably clear that flag whenever an exception occurs so that the extra --force flag is not needed the next time you want to run the command. The original purpose of the check was to prevent people from running the checker twice at the same time.

As for the first problem, this is a bit harder to figure out, as the code that runs against this problem is a bit complex and it's been a while since I've written it.
Can you tell me if you have multiple root categories? And could you maybe briefly explain how your category trees look like and especially where category with id '36764' fits into the tree? A screenshot might help here if are willing to share it publicly.

@Nuranto
Copy link
Author

Nuranto commented Oct 20, 2021

Hello @hostep

Ok thank you for the second problem 馃憤

For the first one, yes I have two root categories, for two websites. 36764 did not exists in catalog_category_entity table, however, there was an entry in url_rewrite. I deleted it, but it seems it doesn't solve the issue, so I guess 36764 is still in another table, but which one ?

@hostep
Copy link
Member

hostep commented Oct 20, 2021

Huh, this is really strange

If I follow the code, the category data is fetched from the database from here, and this does search the catalog_category_entity table.
But since it needs the url_path and url_key attributes, I would suspect that a join is made with the catalog_category_entity_varchar table. So maybe there are still entries in that table with that ID?

If that doesn't help, could you maybe try to debug the code a little bit, to see how and where it goes wrong?

@Nuranto
Copy link
Author

Nuranto commented Oct 20, 2021

I did check all entity tables also, there was no 36764 there.

Ok, I will dig this tomorrow ! I'll keep you informed.

@hostep
Copy link
Member

hostep commented Oct 20, 2021

I took a look at the code again, I believe you might have a category where the path contains the '36764' id.
You can probably find the incorrect categories with a query like this: SELECT * FROM catalog_category_entity WHERE path LIKE '%/36764%';

That probably means those are subcategories of the no-longer existing category with id '36764' and those subcategories will probably not work properly and maybe even not show up in the backend of Magento and can probably be removed as well?

@Nuranto
Copy link
Author

Nuranto commented Oct 21, 2021

Hello, you're right ! That was it. Everything works fine after deleting those.

I don't know how that could happen....

Anyway, thank you very much for your help !

@hostep
Copy link
Member

hostep commented Oct 21, 2021

Great, glad you figured it out!

Let me keep this ticket opened, so I remember to take a look at that 2nd problem, where we should remove the flag that something is running after an exception occurred.

@hostep
Copy link
Member

hostep commented Oct 23, 2021

Release v1.3.1 was made which contains some small improvements based on what you reported here, thanks for that! 馃檪

@hostep hostep closed this as completed Oct 23, 2021
@sajidunnar
Copy link

@Nuranto Can you share whats was your solution did u removed those records from db ?

@Nuranto
Copy link
Author

Nuranto commented Jan 8, 2022

@sajidunnar Yes, I remove duplicated lines, and it solves the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants