I am getting this error in my extension.
PackageName\ModuleName\Block\Enhanced
Incorrect dependency in class PackageName\ModuleName\Block\Enhanced in
/var/www/html/app/code/PackageName/ModuleName/Block/Enhanced.php
\Magento\Store\Model\StoreManagerInterface already exists in context object
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Catalog\Model\Session $catalogSession,
\Magento\Store\Model\StoreManagerInterface $storeManager,
array $data = []
)
{
parent::__construct($context, $data);
$this->_catalogSession = $catalogSession;
$this->_storeManager = $storeManager;
}
Best Answer
You don't need to inject
\Magento\Store\Model\StoreManagerInterface
in your constructor because the parent class already does that.I assume your block extends
Magento\Framework\View\Element\Template
which already has the following code:Thus you can replace your code with: