<?php
namespace App\Grid;
use Doctrine\Common\Collections\Criteria;
use Sylius\Component\Grid\Event\GridDefinitionConverterEvent;
class AdminOrdersGridListener
{
public function addLimitFilter(GridDefinitionConverterEvent $event): void
{
$grid = $event->getGrid();
$dateFilter = $grid->getFilter('createdAt');
if ($dateFilter) {
if (!$dateFilter->getCriteria()) {
$dateFilter->setCriteria(['from' => ['date' => date('Y-m-d', strtotime('- 1 week')), 'time' => '']]);
}
}
}
}