After updating the version, I started getting on all category pages this error: Exception #0 (RuntimeException): Catalog Layer has been already created
This is error in: vendor/magento/module-catalog/Model/Layer/Resolver.php
/**
* Create Catalog Layer by specified type
*
* @param string $layerType
* @return void
*/
public function create($layerType)
{
if (isset($this->layer)) {
throw new \RuntimeException('Catalog Layer has been already created');
}
if (!isset($this->layersPool[$layerType])) {
throw new \InvalidArgumentException($layerType . ' does not belong to any registered layer');
}
$this->layer = $this->objectManager->create($this->layersPool[$layerType]);
}
$layerType = 'category' from vendor/magento/module-catalog/Controller/Category/View.php
/**
* Category view action
*
* @throws NoSuchEntityException
*/
public function execute()
{
$result = null;
if ($this->_request->getParam(ActionInterface::PARAM_NAME_URL_ENCODED)) {
return $this->resultRedirectFactory->create()->setUrl($this->_redirect->getRedirectUrl());
}
$category = $this->_initCategory();
if ($category) {
$this->layerResolver->create(Resolver::CATALOG_LAYER_CATEGORY);
$settings = $this->_catalogDesign->getDesignSettings($category);
// apply custom design
if ($settings->getCustomDesign()) {
$this->_catalogDesign->applyCustomDesign($settings->getCustomDesign());
}
$this->_catalogSession->setLastViewedCategoryId($category->getId());
$page = $this->resultPageFactory->create();
// apply custom layout (page) template once the blocks are generated
if ($settings->getPageLayout()) {
$page->getConfig()->setPageLayout($settings->getPageLayout());
}
$pageType = $this->getPageType($category);
if (!$category->hasChildren()) {
// Two levels removed from parent. Need to add default page type.
$parentPageType = strtok($pageType, '_');
$page->addPageLayoutHandles(['type' => $parentPageType], null, false);
}
$page->addPageLayoutHandles(['type' => $pageType], null, false);
$page->addPageLayoutHandles(['displaymode' => strtolower($category->getDisplayMode())], null, false);
$page->addPageLayoutHandles(['id' => $category->getId()]);
// apply custom layout update once layout is loaded
$this->applyLayoutUpdates($page, $settings);
$page->getConfig()->addBodyClass('page-products')
->addBodyClass('categorypath-' . $this->categoryUrlPathGenerator->getUrlPath($category))
->addBodyClass('category-' . $category->getUrlKey());
return $page;
} elseif (!$this->getResponse()->isRedirect()) {
$result = $this->resultForwardFactory->create()->forward('noroute');
}
return $result;
}
But i can't found where loaded Category Layer too. I check this issue in Google and i found this issue, but without answer. I have Amasty modules like Amasty_Shopby and required modules for him and after disabling this modules i am not getting this error. How can I fix this error without turning off these modules?
Please, help with this issue! Thanks!