Magento – Catalog price rule from today does not apply

catalog-price-rulesce-1.9.1.0

I am using Magento 1.9.1.0. I set up a catalog price rule which applies to all my products in my store with a discount of the 20 percent for just one day.
The catalogrule_apply_all action is supposed to be ran every day at 1am in the mornig (0 1 * * *).

I have a problem in setting the date range of the promotion. To test it, in my development environment, I set up the from_date and the end_date with the 'today' value. After applying the rule I can't see the promotion in the frontend. I need to set up the from_date back of one day to see it working.

Now I have to schedule the promotion, which will start in 2 days, for my production environment and I am not sure about which value assign to from_date field. Should I assign the day before it should be active or should i leave the real start date?

Best Answer

Problem in this instance is on these lines

$fromTime = (int) strtotime($rule->getFromDate());
$toTime = (int) strtotime($rule->getToDate());

They are not using Magento time methods to take in to consideration timing zones and in the comparison it uses following line. (Few lines after the above lines)

$coreDate  = $this->_factory->getModel('core/date');
$timestamp = $coreDate->gmtTimestamp('Today');

If you update the first two lines to

$fromTime = (int) Mage::getModel('core/date')->gmtTimestamp(strtotime($rule->getFromDate()));
$toTime = (int) Mage::getModel('core/date')->gmtTimestamp(strtotime($rule->getToDate()));

Note that now both uses gmtTimestamp which is inline with the comparison. This should work fine. Obviously add a class override.

Related Topic