From Mage/CatalogRule/Model/Resource/Rule.php
/**
* Inserts rule data into catalogrule/rule_product table
*
* @param Mage_CatalogRule_Model_Rule $rule
* @param array $websiteIds
* @param array $productIds
*/
public function insertRuleData(Mage_CatalogRule_Model_Rule $rule, array $websiteIds, array $productIds = array())
{
/** @var $write Varien_Db_Adapter_Interface */
$write = $this->_getWriteAdapter();
$customerGroupIds = $rule->getCustomerGroupIds();
$fromTime = (int) strtotime($rule->getFromDate());
$toTime = (int) strtotime($rule->getToDate());
$toTime = $toTime ? ($toTime + self::SECONDS_IN_DAY - 1) : 0;
/** @var Mage_Core_Model_Date $coreDate */
$coreDate = $this->_factory->getModel('core/date');
$timestamp = $coreDate->gmtTimestamp('Today');
if ($fromTime > $timestamp
|| ($toTime && $toTime < $timestamp)
) {
return;
}
Everything looks fine so far if you put the same for from and to date.
For the to date is date + seconds in a day - 1, so will be end of that day.
Maybe the core date is incorrect because of a conflicting timezone setting.
You could test with a test script and echo some data.
include('app/Mage.php');
Mage::app('admin');
echo date('Ymd His', Mage::getModel('core/date')->gmtTimestamp('today'));
Or invoke the insertRuleData
manually and add some debug data in the resource file for testing.
$ruleId = 1; // Your rule id here
/** @var $rule Mage_CatalogRule_Model_Rule */
$rule = Mage::getModel('catalogrule/rule')->load($ruleId);
/** @var $resource Mage_CatalogRule_Model_Resource_Rule */
$resource = Mage::getResourceModel('catalogrule/rule');
$resource->insertRuleData($rule, array_keys(Mage::app()->getWebsites(true)));