cancel
Showing results for 
Search instead for 
Did you mean: 

After upgrade magento2.4 showing 500 error in block in my new product module

After upgrade magento2.4 showing 500 error in block in my new product module

Hi Guys,

 

After upgrade magento 2.4 my custom newproduct module showing 500 error in block but I am not found where is the issue, Any one can help?

 

<?php

namespace xxx\yyy\Block\Index;

use Magento\Catalog\Api\CategoryRepositoryInterface;

class NewProduct extends \Magento\Catalog\Block\Product\ListProduct
{
    protected $_productnewCollection;
    protected $_productloader;
   protected $_newhelper;

    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\Catalog\Model\ResourceModel\Product\CollectionFactory $productnewCollectionFactory, 
        \Magento\Catalog\Model\ProductFactory $_productloader,
        \xxx\yyy\Helper\Data $newhelper,
        array $data = []) {

        $this->_productnewCollection = $productnewCollectionFactory;
        $this->_productloader = $_productloader;
        $this->_newhelper = $newhelper;
        parent::__construct($context, $postDataHelper, $layerResolver, $categoryRepository, $urlHelper, $data);

    }

    public function getNewProductCollection()
    {
         $collection = $this->_productnewCollection->create();
         $todayDate  = date('Y-m-d');
         $collection->addAttributeToFilter('news_from_date', array('date' => true, 'to' => $todayDate));
         $collection->setPageSize(8);
         $collection->setOrder('position','DESC');
         return $collection;
    }

    public function getNewProduct($entity_id)
    {
        return $this->_productloader->create()->load($entity_id);
    }

}