\Magento\Framework\Registry already exists in context object on compile

Just upload your code same as below,

Keep $this->_coreRegistry = $context->getRegistry();

Full code,

public function __construct(
    \Magento\Catalog\Block\Product\Context $context,
    \Magento\Framework\Data\Helper\PostHelper $postDataHelper,
    \Magento\Catalog\Model\Layer\Resolver $layerResolver,
    CategoryRepositoryInterface $categoryRepository,
    \Magento\Framework\Url\Helper\Data $urlHelper,
    \Magento\Sales\Model\ResourceModel\Report\Bestsellers\CollectionFactory $collectionFactory,
    \Magento\Reports\Model\ResourceModel\Product\CollectionFactory $productsFactory,
    array $data = []
) {
    $this->_collectionFactory = $collectionFactory;
    $this->_productsFactory = $productsFactory;
    $this->_coreRegistry = $context->getRegistry();
    parent::__construct(
        $context,
        $postDataHelper,
        $layerResolver,
        $categoryRepository,
        $urlHelper,
        $data
    );
}

Remove var folder and compile again. Registry is already called inside product block so its display compile errror in your case.


It says that \Magento\Catalog\Block\Product\Context already has \Magento\Framework\Registry in it. So instead of injecting both of them, you should inject only Context and get registry from it via \Magento\Catalog\Block\Product\Context::getRegistry()