Magento – Problematic Category ID? “No such entity with id = 0”

categorydatabasemagento-2.1.2magento2

I've come across a problem I'm not able to handle by myself. I have recently started the process of moving my M1 store over to M2. All in all, a solution like Store Manager from eMagicone makes the task pretty smooth, but some issues are there. I have some problem I do not understand with categories. One of the custom extensions I'm using allows customers to browse through all products but it seems to be something wrong with category entities and throws this error:

a:4:{i:0;s:26:"No such entity with id = 0";i:1;s:16195:"#0 app/code/Magento/Catalog/Model/CategoryRepository.php(141): Magento\Framework\Exception\NoSuchEntityException::singleField('id', '0')

There is also an issue when trying to edit a product, the correct category path is not shown, it only shows root category ID 2, while the product is assigned to a store that is using root category ID 3.

If I disable all custom extensions and only have Magento alone, the error still is there when editing products.

I have trying to add in catalog_category_entity a field with entity_id 0, since it started from 1. No difference, exact same error message is shown.

This is clearly some error in DB, could any one help me with some suggestions?

Magento 2.1.2 – Php 7.0.X, MariaDB 10.0.X

Other than on that specific page for that custom module, there is no issues on frontend that can be linked to the same. When browsing through layered navigation, all categories shows up where they should..

Complete stack trace:

> a:4:{i:0;s:26:"No such entity with id = 0";i:1;s:16195:"#0 app/code/Magento/Catalog/Model/CategoryRepository.php(141): Magento\Framework\Exception\NoSuchEntityException::singleField('id','0')
>     #1 app/code/Magento/Catalog/Model/Category.php(685):
> Magento\Catalog\Model\CategoryRepository->get('0')
>     #2 var/generation/Magento/Catalog/Model/Category/Interceptor.php(232):
> Magento\Catalog\Model\Category->getParentCategory()
>     #3 vendor/mirasvit/module-seo/src/Seo/Model/SeoObject/Category.php(124):
> Magento\Catalog\Model\Category\Interceptor->getParentCategory()
>     #4 vendor/mirasvit/module-seo/src/Seo/Model/SeoObject/Category.php(92):
> Mirasvit\Seo\Model\SeoObject\Category->_construct()
>     #5 lib/internal/Magento/Framework/ObjectManager/Factory/AbstractFactory.php(93):
> Mirasvit\Seo\Model\SeoObject\Category->__construct(Object(Magento\Framework\Registry),
> Object(Magento\Store\Model\StoreManager),
> Object(Mirasvit\Seo\Model\SeoObject\StoreFactory),
> Object(Mirasvit\Seo\Model\SeoObject\PagerFactory),
> Object(Mirasvit\Seo\Model\SeoObject\Wrapper\FilterFactory),
> Object(Magento\Catalog\Model\ResourceModel\Category\CollectionFactory),
> Object(Mirasvit\Seo\Model\Config),
> Object(Magento\Framework\Stdlib\StringUtils))
>     #6 lib/internal/Magento/Framework/ObjectManager/Factory/Dynamic/Developer.php(89):
> Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Mirasvit\\Seo\\Mo...',
> Array)
>     #7 lib/internal/Magento/Framework/ObjectManager/ObjectManager.php(71):
> Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Mirasvit\\Seo\\Mo...')
>     #8 vendor/mirasvit/module-seo/src/Seo/Helper/Data.php(669):
> Magento\Framework\ObjectManager\ObjectManager->get('Mirasvit\\Seo\\Mo...')
>     #9 vendor/mirasvit/module-seo/src/Seo/Observer/SeoDataObserver.php(92):
> Mirasvit\Seo\Helper\Data->getCurrentSeo()
>     #10 vendor/mirasvit/module-seo/src/Seo/Observer/SeoDataObserver.php(209):
> Mirasvit\Seo\Observer\SeoDataObserver->applyMeta(Object(Magento\Framework\Event\Observer))
>     #11 lib/internal/Magento/Framework/Event/Invoker/InvokerDefault.php(73):
> Mirasvit\Seo\Observer\SeoDataObserver->execute(Object(Magento\Framework\Event\Observer))
>     #12 lib/internal/Magento/Framework/Event/Invoker/InvokerDefault.php(61):
> Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod(Object(Mirasvit\Seo\Observer\SeoDataObserver),
> Object(Magento\Framework\Event\Observer))
>     #13 lib/internal/Magento/Framework/Interception/Interceptor.php(146):
> Magento\Framework\Event\Invoker\InvokerDefault->dispatch(Array,
> Object(Magento\Framework\Event\Observer))
>     #14 var/generation/Magento/Framework/Event/Invoker/InvokerDefault/Interceptor.php(26):
> Magento\Framework\Event\Invoker\InvokerDefault\Interceptor->___callPlugins('dispatch',
> Array, Array)
>     #15 lib/internal/Magento/Framework/Event/Manager.php(66):
> Magento\Framework\Event\Invoker\InvokerDefault\Interceptor->dispatch(Array,
> Object(Magento\Framework\Event\Observer))
>     #16 var/generation/Magento/Framework/Event/Manager/Proxy.php(95):
> Magento\Framework\Event\Manager->dispatch('controller_acti...', Array)
>     #17 lib/internal/Magento/Framework/App/Action/Action.php(113):
> Magento\Framework\Event\Manager\Proxy->dispatch('controller_acti...',
> Array)
>     #18 lib/internal/Magento/Framework/Interception/Interceptor.php(74):
> Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
>     #19 lib/internal/Magento/Framework/Interception/Chain/Chain.php(70):
> Amasty\ShopbyRoot\Controller\Index\Index\Interceptor->___callParent('dispatch',
> Array)
>     #20 lib/internal/Magento/Framework/Interception/Chain/Chain.php(63):
> Magento\Framework\Interception\Chain\Chain->invokeNext('Amasty\\ShopbyRo...',
> 'dispatch',
> Object(Amasty\ShopbyRoot\Controller\Index\Index\Interceptor), Array,
> 'contextPlugin')
>     #21 app/code/Magento/Store/App/Action/Plugin/Context.php(106):
> Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
>     #22 lib/internal/Magento/Framework/Interception/Chain/Chain.php(67):
> Magento\Store\App\Action\Plugin\Context->aroundDispatch(Object(Amasty\ShopbyRoot\Controller\Index\Index\Interceptor),
> Object(Closure), Object(Magento\Framework\App\Request\Http))
>     #23 lib/internal/Magento/Framework/Interception/Chain/Chain.php(63):
> Magento\Framework\Interception\Chain\Chain->invokeNext('Amasty\\ShopbyRo...',
> 'dispatch',
> Object(Amasty\ShopbyRoot\Controller\Index\Index\Interceptor), Array,
> 'customer-app-ac...')
>     #24 app/code/Magento/Customer/Model/App/Action/ContextPlugin.php(61):
> Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
>     #25 lib/internal/Magento/Framework/Interception/Chain/Chain.php(67):
> Magento\Customer\Model\App\Action\ContextPlugin->aroundDispatch(Object(Amasty\ShopbyRoot\Controller\Index\Index\Interceptor),
> Object(Closure), Object(Magento\Framework\App\Request\Http))
>     #26 lib/internal/Magento/Framework/Interception/Chain/Chain.php(63):
> Magento\Framework\Interception\Chain\Chain->invokeNext('Amasty\\ShopbyRo...',
> 'dispatch',
> Object(Amasty\ShopbyRoot\Controller\Index\Index\Interceptor), Array,
> 'storeCheck')
>     #27 app/code/Magento/Store/App/Action/Plugin/StoreCheck.php(44):
> Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
>     #28 lib/internal/Magento/Framework/Interception/Chain/Chain.php(67):
> Magento\Store\App\Action\Plugin\StoreCheck->aroundDispatch(Object(Amasty\ShopbyRoot\Controller\Index\Index\Interceptor),
> Object(Closure), Object(Magento\Framework\App\Request\Http))
>     #29 lib/internal/Magento/Framework/Interception/Chain/Chain.php(63):
> Magento\Framework\Interception\Chain\Chain->invokeNext('Amasty\\ShopbyRo...',
> 'dispatch',
> Object(Amasty\ShopbyRoot\Controller\Index\Index\Interceptor), Array,
> 'weee-app-action...')
>     #30 app/code/Magento/Weee/Model/App/Action/ContextPlugin.php(112):
> Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
>     #31 lib/internal/Magento/Framework/Interception/Chain/Chain.php(67):
> Magento\Weee\Model\App\Action\ContextPlugin->aroundDispatch(Object(Amasty\ShopbyRoot\Controller\Index\Index\Interceptor),
> Object(Closure), Object(Magento\Framework\App\Request\Http))
>     #32 lib/internal/Magento/Framework/Interception/Interceptor.php(138):
> Magento\Framework\Interception\Chain\Chain->invokeNext('Amasty\\ShopbyRo...',
> 'dispatch',
> Object(Amasty\ShopbyRoot\Controller\Index\Index\Interceptor), Array,
> 'tax-app-action-...')
>     #33 app/code/Magento/Tax/Model/App/Action/ContextPlugin.php(91):
> Amasty\ShopbyRoot\Controller\Index\Index\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
>     #34 lib/internal/Magento/Framework/Interception/Interceptor.php(142):
> Magento\Tax\Model\App\Action\ContextPlugin->aroundDispatch(Object(Amasty\ShopbyRoot\Controller\Index\Index\Interceptor),
> Object(Closure), Object(Magento\Framework\App\Request\Http))
>     #35 var/generation/Amasty/ShopbyRoot/Controller/Index/Index/Interceptor.php(39):
> Amasty\ShopbyRoot\Controller\Index\Index\Interceptor->___callPlugins('dispatch',
> Array, Array)
>     #36 lib/internal/Magento/Framework/App/FrontController.php(55): Amasty\ShopbyRoot\Controller\Index\Index\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
>     #37 lib/internal/Magento/Framework/Interception/Interceptor.php(74):
> Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
>     #38 lib/internal/Magento/Framework/Interception/Chain/Chain.php(70):
> Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch',
> Array)
>     #39 lib/internal/Magento/Framework/Interception/Chain/Chain.php(63):
> Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...',
> 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor),
> Array, 'requestPreproce...')
>     #40 app/code/Magento/Store/App/FrontController/Plugin/RequestPreprocessor.php(94):
> Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
>     #41 lib/internal/Magento/Framework/Interception/Chain/Chain.php(67):
> Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor),
> Object(Closure), Object(Magento\Framework\App\Request\Http))
>     #42 lib/internal/Magento/Framework/Interception/Chain/Chain.php(63):
> Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...',
> 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor),
> Array, 'install')
>     #43 lib/internal/Magento/Framework/Module/Plugin/DbStatusValidator.php(69):
> Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
>     #44 lib/internal/Magento/Framework/Interception/Chain/Chain.php(67):
> Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor),
> Object(Closure), Object(Magento\Framework\App\Request\Http))
>     #45 lib/internal/Magento/Framework/Interception/Chain/Chain.php(63):
> Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...',
> 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor),
> Array, 'searchautocompl...')
>     #46 vendor/mirasvit/module-search-autocomplete/src/SearchAutocomplete/Model/App/FrontController/Plugin.php(130):
> Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
>     #47 lib/internal/Magento/Framework/Interception/Chain/Chain.php(67):
> Mirasvit\SearchAutocomplete\Model\App\FrontController\Plugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor),
> Object(Closure), Object(Magento\Framework\App\Request\Http))
>     #48 lib/internal/Magento/Framework/Interception/Chain/Chain.php(63):
> Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...',
> 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor),
> Array, 'Amasty_Finder::...')
>     #49 app/code/Amasty/Finder/Plugin/FrontController/Redirect.php(67):
> Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
>     #50 lib/internal/Magento/Framework/Interception/Chain/Chain.php(67):
> Amasty\Finder\Plugin\FrontController\Redirect->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor),
> Object(Closure), Object(Magento\Framework\App\Request\Http))
>     #51 lib/internal/Magento/Framework/Interception/Chain/Chain.php(63):
> Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...',
> 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor),
> Array, 'front-controlle...')
>     #52 app/code/Magento/PageCache/Model/App/FrontController/VarnishPlugin.php(55):
> Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
>     #53 lib/internal/Magento/Framework/Interception/Chain/Chain.php(67):
> Magento\PageCache\Model\App\FrontController\VarnishPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor),
> Object(Closure), Object(Magento\Framework\App\Request\Http))
>     #54 lib/internal/Magento/Framework/Interception/Interceptor.php(138):
> Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...',
> 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor),
> Array, 'front-controlle...')
>     #55 vendor/mirasvit/module-seo/src/Seo/Plugin/Event/BuiltinPlugin.php(95):
> Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
>     #56 lib/internal/Magento/Framework/Interception/Interceptor.php(142):
> Mirasvit\Seo\Plugin\Event\BuiltinPlugin->aroundAroundDispatch(Object(Magento\PageCache\Model\App\FrontController\BuiltinPlugin\Interceptor),
> Object(Closure),
> Object(Magento\Framework\App\FrontController\Interceptor),
> Object(Closure), Object(Magento\Framework\App\Request\Http))
>     #57 var/generation/Magento/PageCache/Model/App/FrontController/BuiltinPlugin/Interceptor.php(26):
> Magento\PageCache\Model\App\FrontController\BuiltinPlugin\Interceptor->___callPlugins('aroundDispatch',
> Array, Array)
>     #58 lib/internal/Magento/Framework/Interception/Interceptor.php(142):
> Magento\PageCache\Model\App\FrontController\BuiltinPlugin\Interceptor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor),
> Object(Closure), Object(Magento\Framework\App\Request\Http))
>     #59 var/generation/Magento/Framework/App/FrontController/Interceptor.php(26):
> Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch',
> Array, Array)
>     #60 lib/internal/Magento/Framework/App/Http.php(135):
> Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
>     #61 lib/internal/Magento/Framework/App/Bootstrap.php(258):
> Magento\Framework\App\Http->launch()
>     #62 index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
>     #63 {main}";s:3:"url";s:23:"/komplett-katalog";s:11:"script_name";s:16:"/index.php";}

Best Answer

I faced a similar issue. I solved it by removing the entries which have target_path LIKE %/category/0% from url_rewrites table.

Check out this forum

Related Topic