2

I want to add a two year interval filter to customer order by report grid ,but I have no idea about this.Anyone who have tried it please find me a way ,thanks in advance. I found to add code here in this path app\code\core\Mage\Reports\Model\Resource\Report\Collection.php
and code for a year interval is

$t['title'] =  $dateStart->toString('yyyy');
                        $t['start'] = ($firstInterval) ? $dateStart->toString('yyyy-MM-dd 00:00:00')
                            : $dateStart->toString('yyyy-01-01 00:00:00');

                        $lastInterval = ($dateStart->compareYear($dateEnd->getYear()) == 0);

                        $t['end'] = ($lastInterval) ? $dateStart->setMonth($dateEnd->getMonth())
                            ->setDay($dateEnd->getDay())->toString('yyyy-MM-dd 23:59:59')
                            : $dateStart->toString('yyyy-12-31 23:59:59');
                        $dateStart->addYear(1);

                        if ($dateStart->compareYear($dateEnd->getYear()) == 0) {
                            $dateStart->setMonth(1)->setDay(1);

                        $firstInterval = false;
                        break;
                        }

How can i modify this for two year interval period.

1 Answer 1

0

I got it done for me, here is the code

case '2year':
                        $t['title'] =  $dateStart->toString('yyyy').'-'.($dateStart->toString('yyyy')+1);
                        $t['start'] = ($firstInterval) ? $dateStart->toString('yyyy-MM-dd 00:00:00')
                            : $dateStart->toString('yyyy-01-01 00:00:00');

                        $lastInterval = ($dateStart->compareYear($dateEnd->getYear()) == 0);
                        Mage::log($lastInterval);
                        $t['end'] = ($lastInterval) ? $dateStart->setYear($dateEnd->getYear())->setMonth($dateEnd->getMonth())
                            ->setDay($dateEnd->getDay())->toString('yyyy-MM-dd 23:59:59')
                            : $dateStart->toString('yyyy-12-31 23:59:59');
                        $dateStart->addYear(2);

                        if ($dateStart->compareYear($dateEnd->getYear()) == 0) {
                            $dateStart->setMonth(1)->setDay(1);
                          }  
                        $firstInterval = false;
                        break;

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.