1

I'm getting the following error: Incompatible argument type: Required type: \Magento\Framework\Data\Helper\PostHelper. Actual type: array.

I have tried changing the parent constructor, but I'm still getting the same error.

I also tried extending:

extends \Magento\Framework\View\Element\Template implements \Magento\Widget\Block\BlockInterface

still, getting the same error.

posting the relevant part of my code:

class ProductList extends \Magento\Catalog\Block\Product\ListProduct
{
    protected $_logger;
    protected $_searchCriteriaBuilder;
    protected $_productRepository;
    protected $_categoryRepository;
    protected $_storeManager;
    protected $_categoryFactory;
    protected $_filterBuilder;


    public function __construct(
        \Magento\Catalog\Block\Product\Context $context,
        \Magento\Framework\Data\Helper\PostHelper $postDataHelper,
        \Magento\Catalog\Api\CategoryRepositoryInterface $categoryRepository,
        \Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
        \Magento\Framework\Api\FilterBuilder $filterBuilder,
        \Magento\Store\Model\StoreManagerInterface $storeManager,
        \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder,
        \Magento\Catalog\Model\Layer\Resolver $layerResolver,
        \Magefan\Blog\Model\CategoryFactory $categoryFactory,
        \Magento\Framework\Url\Helper\Data $urlHelper,
        \Psr\Log\LoggerInterface $logger,
        array $data = []
    )
    {
        $this->_logger = $logger;
        $this->_productRepository = $productRepository;
        $this->_filterBuilder = $filterBuilder;
        $this->_storeManager = $storeManager;
        $this->_searchCriteriaBuilder = $searchCriteriaBuilder;
        $this->_categoryRepository = $categoryRepository;
        $this->_categoryFactory = $categoryFactory;
    //    parent::_construct();
    //    parent::__construct($context, $data);
        parent::__construct($context, $postDataHelper, $layerResolver, $categoryRepository, $urlHelper, $data);
    }

Can anyone please assist?

1 Answer 1

0

Update the file calling $postDataHelper

class ProductList extends \Magento\Catalog\Block\Product\ListProduct
{
protected $_logger;
protected $_searchCriteriaBuilder;
protected $_productRepository;
protected $_categoryRepository;
protected $_storeManager;
protected $_categoryFactory;
protected $_filterBuilder;
protected $_postDataHelper,


public function __construct(
    \Magento\Catalog\Block\Product\Context $context,
    \Magento\Framework\Data\Helper\PostHelper $postDataHelper,
    \Magento\Catalog\Api\CategoryRepositoryInterface $categoryRepository,
    \Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
    \Magento\Framework\Api\FilterBuilder $filterBuilder,
    \Magento\Store\Model\StoreManagerInterface $storeManager,
    \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder,
    \Magento\Catalog\Model\Layer\Resolver $layerResolver,
    \Magefan\Blog\Model\CategoryFactory $categoryFactory,
    \Magento\Framework\Url\Helper\Data $urlHelper,
    \Psr\Log\LoggerInterface $logger,
    array $data = []
)
{
    $this->_logger = $logger;
    $this->_postDataHelper = $postDataHelper;
    $this->_productRepository = $productRepository;
    $this->_filterBuilder = $filterBuilder;
    $this->_storeManager = $storeManager;
    $this->_searchCriteriaBuilder = $searchCriteriaBuilder;
    $this->_categoryRepository = $categoryRepository;
    $this->_categoryFactory = $categoryFactory;
 parent::__construct($context, $postDataHelper, $layerResolver, $categoryRepository, $urlHelper, $data);
}

rm -rf var/cache/ var/page_cache/ var/view_preprocessed/ pub/static/ generated/*

bin/magento setup:di:compile
7
  • I'm still getting the same error. Sep 11, 2019 at 8:31
  • can you please explain, what do you mean: "Update the file calling $postDataHelper"? Sep 11, 2019 at 8:35
  • you have missed this part cl.ly/5d96f284c5e4 Sep 11, 2019 at 8:38
  • I'm still getting the same error Sep 11, 2019 at 8:45
  • you need to run the command i showed you , also bin/magento setup:static-content:deploy , you might declare $layerResolver . Sep 11, 2019 at 8:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.