1

I want to override Magento Reports module and it's not working. here's my code :

di.xml

<preference for="Magento\Reports\Model\ResourceModel\Report\Collection" type="SZK\Shamsi\Model\ResourceModel\Report\Collection" />

SZK\Shamsi\Model\ResourceModel\Report\Collection


namespace SZK\Shamsi\Model\ResourceModel\Report;

use Magento\Reports\Model\ResourceModel\Report\Collection as OrgCollection;
use Morilog\Jalali\jDate;

class Collection extends OrgCollection
{

    /**
     * @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
     * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
     * @param \Magento\Reports\Model\ResourceModel\Report\Collection\Factory $collectionFactory
     */
    public function __construct(
        \Magento\Framework\Data\Collection\EntityFactory $entityFactory,
        \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
        \Magento\Reports\Model\ResourceModel\Report\Collection\Factory $collectionFactory
    )
    {
        parent::__construct($entityFactory, $localeDate, $collectionFactory);
    }

    /**
     * @param \DateTime $dateStart
     * @return array
     * @throws \Magento\Framework\Exception\LocalizedException
     */
    protected function _getDayInterval(\DateTime $dateStart)
    {
        $interval = [
            'period' => jDate::forge($dateStart)->format('Y-m-d'),
            'start' => $this->_localeDate->convertConfigTimeToUtc($dateStart->format('Y-m-d 00:00:00')),
            'end' => $this->_localeDate->convertConfigTimeToUtc($dateStart->format('Y-m-d 23:59:59')),
        ];
        return $interval;
    }
}

everything seems ok but it's not working.

3
  • where is the location of your di.xml Commented Jul 19, 2021 at 10:28
  • Check your custom and third party modules , same class is override or not in any modules. Commented Jul 19, 2021 at 10:47
  • di file is in etc, and no, it's not override by thrd party modules. Commented Jul 20, 2021 at 5:36

0

Your Answer

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

Browse other questions tagged or ask your own question.