Skip to main content
added 493 characters in body
Source Link
Abdul
  • 9.7k
  • 1
  • 21
  • 43

Try this :

    protected $_productCollectionFactory;

    public function __construct(
        \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,
        array $data = \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;[]
    ) {
        $this->_productCollectionFactory = $productCollectionFactory;
        parent::__construct($data);
    }


    
    public function getProductCollection()
    {
        /** @var $collection \Magento\Catalog\Model\ResourceModel\Product\Collection */
        $collection = $productCollectionFactory$this->_productCollectionFactory->create();
        return $collection;
    }

Try this :

$productCollectionFactory = \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;    
$collection = $productCollectionFactory->create();

Try this :

    protected $_productCollectionFactory;

    public function __construct(
        \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,
        array $data = []
    ) {
        $this->_productCollectionFactory = $productCollectionFactory;
        parent::__construct($data);
    }


    
    public function getProductCollection()
    {
        /** @var $collection \Magento\Catalog\Model\ResourceModel\Product\Collection */
        $collection = $this->_productCollectionFactory->create();
        return $collection;
    }
Source Link
Abdul
  • 9.7k
  • 1
  • 21
  • 43

Try this :

$productCollectionFactory = \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;    
$collection = $productCollectionFactory->create();