I have been having this issue for several weeks now and after looking through similar issues on this site and others, I still can't figure out how to solve this problem.
After successfully executing setup:di:compile
, the var/di
folder gets created in my Magento directory. my homepage and CMS pages keep working fine, but after compilation I noticed my category pages (for ex. domain.com/shop
) give me the following error:
Fatal error: Uncaught TypeError: Argument 1 passed to Plazathemes\LayeredNavigation\Controller\Category\View::__construct() must be an instance of Magento\Framework\App\Action\Context, instance of Magento\Framework\ObjectManager\ObjectManager given, called in directory/www/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 93 and defined in directory/www/app/code/Plazathemes/Layerednavigation/Controller/Category/View.php:27 Stack trace: #0 directory/www/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(93): Plazathemes\LayeredNavigation\Controller\Category\View->__construct(Object(Magento\Framework\ObjectManager\ObjectManager)) #1 directory/www/vendor/magento/framework/ObjectManager/Factory/Compiled.php(88): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Plazathemes\Lay...', Array) #2 directory/www/vendor/magento/framework/ObjectManager/ObjectManager.php(57): Magento\F in directory/www/app/code/Plazathemes/Layerednavigation/Controller/Category/View.php on line 27
My code/Plazathemes/LayeredNavigation/Controller/Category/View
file starts with this:
class View extends \Magento\Catalog\Controller\Category\View
{
private $layerResolver;
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Catalog\Model\Design $catalogDesign,
\Magento\Catalog\Model\Session $catalogSession,
\Magento\Framework\Registry $coreRegistry,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator $categoryUrlPathGenerator,
PageFactory $resultPageFactory,
\Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory,
Resolver $layerResolver,
CategoryRepositoryInterface $categoryRepository
)
{
parent::__construct($context, $catalogDesign, $catalogSession, $coreRegistry, $storeManager, $categoryUrlPathGenerator, $resultPageFactory, $resultForwardFactory, $layerResolver, $categoryRepository);
$this->layerResolver = $layerResolver;
}
public function execute()
{
// somthing
}
}
I contacted my theme support but they told me this error is not a result of a bug in their theme.
Anyone who can help me figure this out? I'm fairly new to Magento and quite overwhelmed by all these errors. I've already sorted out most of my problems and errors, but this one keeps coming back.
If you need any additional code, please let me know.
I'm running Magento 2.1.5
EDIT: FYI when I delete my var/di
folder or just the global.ser
and frontend.ser
files in it, the category pages work again but uncompiled, making them extremely slow to load. So I need to sort this out in order to have my compiled files working.
/www/app/code/Plazathemes/Layerednavigation/Controller/Category/View.php on line 27