Tonight, I was changing my website and all of a sudden, I received a strange error. I decided to just restore to my last server backup, but that did not help (wtf?).
This is what I see in my latest report from /var/report/
{"0":"Could not load Sales Channels for Stock","1":"#1 Magento\Inventory\Model\StockRepository\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]\n#2 Magento\Inventory\Model\StockRepository\Interceptor->___callPlugins() called at [generated/code/Magento/Inventory/Model/StockRepository/Interceptor.php:32]\n#3 Magento\Inventory\Model\StockRepository\Interceptor->get() called at [vendor/magento/module-inventory-sales/Model/GetStockBySalesChannel.php:57]\n#4 Magento\InventorySales\Model\GetStockBySalesChannel->execute() called at [vendor/magento/framework/Interception/Interceptor.php:58]\n#5 Magento\InventorySales\Model\GetStockBySalesChannel\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]\n#6 Magento\InventorySales\Model\GetStockBySalesChannel\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-inventory-catalog/Plugin/InventorySalesApi/StockResolver/AdaptStockResolverToAdminWebsitePlugin.php:60]\n#7 Magento\InventoryCatalog\Plugin\InventorySalesApi\StockResolver\AdaptStockResolverToAdminWebsitePlugin->aroundExecute() called at [vendor/magento/framework/Interception/Interceptor.php:135]\n#8 Magento\InventorySales\Model\GetStockBySalesChannel\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]\n#9 Magento\InventorySales\Model\GetStockBySalesChannel\Interceptor->___callPlugins() called at [generated/code/Magento/InventorySales/Model/GetStockBySalesChannel/Interceptor.php:23]\n#10 Magento\InventorySales\Model\GetStockBySalesChannel\Interceptor->execute() called at [vendor/magento/module-inventory-sales/Model/GetStockBySalesChannelCache.php:46]\n#11 Magento\InventorySales\Model\GetStockBySalesChannelCache->execute() called at [vendor/magento/framework/Interception/Interceptor.php:58]\n#12 Magento\InventorySales\Model\GetStockBySalesChannelCache\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]\n#13 Magento\InventorySales\Model\GetStockBySalesChannelCache\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-inventory-catalog/Plugin/InventorySalesApi/StockResolver/AdaptStockResolverToAdminWebsitePlugin.php:60]\n#14 Magento\InventoryCatalog\Plugin\InventorySalesApi\StockResolver\AdaptStockResolverToAdminWebsitePlugin->aroundExecute() called at [vendor/magento/framework/Interception/Interceptor.php:135]\n#15 Magento\InventorySales\Model\GetStockBySalesChannelCache\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]\n#16 Magento\InventorySales\Model\GetStockBySalesChannelCache\Interceptor->___callPlugins() called at [generated/code/Magento/InventorySales/Model/GetStockBySalesChannelCache/Interceptor.php:23]\n#17 Magento\InventorySales\Model\GetStockBySalesChannelCache\Interceptor->execute() called at [vendor/magento/module-inventory-sales/Model/StockResolver.php:54]\n#18 Magento\InventorySales\Model\StockResolver->execute() called at [vendor/magento/module-inventory-catalog/Model/GetStockIdForCurrentWebsite.php:48]\n#19 Magento\InventoryCatalog\Model\GetStockIdForCurrentWebsite->execute() called at [vendor/magento/module-inventory-catalog/Plugin/CatalogInventory/Model/ResourceModel/Stock/Status/AdaptAddStockDataToCollectionPlugin.php:57]\n#20 Magento\InventoryCatalog\Plugin\CatalogInventory\Model\ResourceModel\Stock\Status\AdaptAddStockDataToCollectionPlugin->aroundAddStockDataToCollection() called at [vendor/magento/framework/Interception/Interceptor.php:135]\n#21 Magento\CatalogInventory\Model\ResourceModel\Stock\Status\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]\n#22 Magento\CatalogInventory\Model\ResourceModel\Stock\Status\Interceptor->___callPlugins() called at [generated/code/Magento/CatalogInventory/Model/ResourceModel/Stock/Status/Interceptor.php:32]\n#23 Magento\CatalogInventory\Model\ResourceModel\Stock\Status\Interceptor->addStockDataToCollection() called at [vendor/magento/module-catalog-inventory/Helper/Stock.php:165]\n#24 Magento\CatalogInventory\Helper\Stock->addIsInStockFilterToCollection() called at [vendor/magento/module-catalog-inventory/Model/AddStockStatusToCollection.php:40]\n#25 Magento\CatalogInventory\Model\AddStockStatusToCollection->beforeLoad() called at [vendor/magento/framework/Interception/Interceptor.php:121]\n#26 Mageplaza\LayeredNavigation\Model\ResourceModel\Fulltext\Collection\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]\n#27 Mageplaza\LayeredNavigation\Model\ResourceModel\Fulltext\Collection\Interceptor->___callPlugins() called at [generated/code/Mageplaza/LayeredNavigation/Model/ResourceModel/Fulltext/Collection/Interceptor.php:32]\n#28 Mageplaza\LayeredNavigation\Model\ResourceModel\Fulltext\Collection\Interceptor->load() called at [vendor/magento/framework/Data/Collection.php:839]\n#29 Magento\Framework\Data\Collection->getIterator() called at [vendor/magento/module-catalog/Block/Product/ListProduct.php:366]\n#30 Magento\Catalog\Block\Product\ListProduct->getIdentities() called at [vendor/magento/module-page-cache/Model/Layout/LayoutPlugin.php:96]\n#31 Magento\PageCache\Model\Layout\LayoutPlugin->afterGetOutput() called at [vendor/magento/framework/Interception/Interceptor.php:146]\n#32 Magento\Framework\View\Layout\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]\n#33 Magento\Framework\View\Layout\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:41]\n#34 Magento\Framework\View\Layout\Interceptor->getOutput() called at [vendor/magento/framework/View/Result/Page.php:260]\n#35 Magento\Framework\View\Result\Page->render() called at [vendor/magento/framework/View/Result/Layout.php:171]\n#36 Magento\Framework\View\Result\Layout->renderResult() called at [vendor/magento/framework/Interception/Interceptor.php:58]\n#37 Magento\Framework\View\Result\Page\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]\n#38 Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/mirasvit/module-optimize/src/Optimize/Plugin/Framework/Controller/Result/OutputProcessorPlugin.php:54]\n#39 Mirasvit\Optimize\Plugin\Framework\Controller\Result\OutputProcessorPlugin->aroundRenderResult() called at [vendor/magento/framework/Interception/Interceptor.php:135]\n#40 Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]\n#41 Magento\Framework\View\Result\Page\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/View/Result/Page/Interceptor.php:23]\n#42 Magento\Framework\View\Result\Page\Interceptor->renderResult() called at [vendor/magento/framework/App/Http.php:120]\n#43 Magento\Framework\App\Http->launch() called at [vendor/magento/framework/App/Bootstrap.php:264]\n#44 Magento\Framework\App\Bootstrap->run() called at [pub/index.php:29]\n","url":"/laptopi.html","script_name":"/pub/index.php","report_id":"3e8063fed78e5c667509793afdf9648423ea8a8ca1e582b68f8cc748ff854bba"}
I've done upgrades, compilations, static files deployment, cache clearing, reindexing...and everything else multiple times, but nothing has helped. I've also tried it from both dev and prod mode, that didn't help. I ended up restarting Redis, MySQL, Apache...still nothing.
Anyone knows how I can fix this? Earlier today, everything is fine. But even when I restart my server to that point, the website still doesn't work.
Solution 1:
check that all the modules related to inventory are enabled using this command :
php bin/magento module:status
You will see a list of enabled and disabled modules. If any module is disable so you can enable these with the module:enable command or by editing the app/etc/config.php file and changing the status of disabled modules (0) to 1.
Remember to run setup:upgrade after making any changes to config.php.
Solution 2:
Try to remove the var/generated folder & run all the magento commands.
rm -rf var/ generated/ php bin/magento se:up php bin/magento s:d:c php bin/magento s:s:d -f php bin/magento c:f