Your issue is that you need to be able to tell the rules that the special is current active.
I have had the same issue in my Dynamic Category Products Extension, in that I needed to allow date range attributes to consider the dates that the attribute is active on. To make it more complex, you would need to consider the date range set to be in range on the day the category (or in your case, the product) is viewed.
I thus came up with a new rule condition that is as such:
Explaining how I did that would really take a bit of time, and the code is quite heavily integrated into the extensions code (as I added many other rule types)
What I can give you, and which you would be able to apply to any collection, is the way I altered the collection to filter out any products that are currently on special, taking into consideration the date range.
$collection is the actual product collection, as loaded from the current category.
The block below is the code I use in the validation routine for product attributes, and some parts will be out of contect. Please ask if you need some bits/parts further explained.
Basically it ads in a filter to the product collection, that includes (or excludes) products that has active special price to form date ranges.
case 'date':
$todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATE_INTERNAL_FORMAT);
switch ($operator) {
case 'inrange':
//TO
$collection->addAttributeToFilter(
array(
array(
'attribute' => $attrCode,
'null' => true
),
array(
'attribute' => $attrCode,
'from' => $todayDate,
//'to' => $todayDate,
'date' => true
)
)
);
// FROM
$attrCodeFrom = str_replace('to', 'from', $attrCode);
if (array_key_exists($attrCode, $this->_dropAtrribute)) {
$attrCodeFrom = $this->_dropAtrribute[$attrCode];
}
$collection->addAttributeToFilter(
array(
array(
'attribute' => $attrCodeFrom,
'null' => true
),
array(
'attribute' => $attrCodeFrom,
//'from' => $todayDate,
'to' => $todayDate,
'date' => true
)
)
);
// skip where both dates are null.
$collection->addAttributeToFilter(
array(
array(
'attribute' => $attrCode,
'notnull' => true
),
array(
'attribute' => $attrCodeFrom,
'notnull' => true
)
)
);
$collection->setFlag('applied_date_ranges_' . $attrCode, true);
break;
case 'ninrange': // inverted
//TO
$collection->addAttributeToFilter(
array(
array(
'attribute' => $attrCode,
'null' => true
),
array(
'attribute' => $attrCode,
'to' => $todayDate,
//'to' => $todayDate,
'date' => true
)
)
);
// FROM
$attrCodeFrom = str_replace('to', 'from', $attrCode);
$collection->addAttributeToFilter(
array(
array(
'attribute' => $attrCodeFrom,
'null' => true
),
array(
'attribute' => $attrCodeFrom,
//'from' => $todayDate,
'from' => $todayDate,
'date' => true
)
)
);
// skip where both dates are null.
$collection->addAttributeToFilter(
array(
array(
'attribute' => $attrCode,
'notnull' => true
),
array(
'attribute' => $attrCodeFrom,
'notnull' => true
)
)
);
$collection->setFlag('applied_date_ranges_' . $attrCode, true);
break;
case 'xdaysago':
$days = ($value == 1) ? 'day' : 'days';
$startDate = date('Y-m-d', strtotime('-' . $value . ' ' . $days, strtotime($todayDate)));
$collection->addAttributeToFilter(
array(
array(
'attribute' => $attrCode,
'gteq' => $startDate,
'date' => true
)
)
);
$collection->addAttributeToFilter(
array(
array(
'attribute' => $attrCode,
'notnull' => true
),
)
);
break;
default:
// all other date attributes
$collection->addAttributeToFilter(
array(
array(
'attribute' => $attrCode,
$operator => $value,
'date' => true
)
)
);
$collection->addAttributeToFilter(
array(
array(
'attribute' => $attrCode,
'notnull' => true
),
)
);
break;
}
break;
Hope this is of use to you.
One day, when I have time, I'd like to extract that rule (and some others I created) and build a community module that extends core catalog rules. One day, when I have time!!
Best Answer
Catalog price rules Need Cron jobs. install this extension and check whether cron is working or not. if it is working check your Default Store Timezone is matching your server timezone.
credits : @Alexei Yerofeyev
if both timings are same, than Yes, this is a bug in Magento (or some logic beyond my understanding). we had the same problem. When Magento displays products on frontend, it checks if there are catalog rules for this date. And the date used for this check is your local, so in our case it was GMT+5. However, when catalog rules are being applied, it uses GMT date. So that means that we were't able to apply rules until 5 AM.
The problem is in Mage_CatalogRule_Model_Action_Index_Refresh::execute() function. You will have to rewrite this function/class either in your extension, or via the local version of the file.
we replaced line 121:
with this line:
After that it worked for us.
if that also didt worked for you, than
using AOE scheduler extension, change
catalogrule_apply_all
cron expression from0 1 * * *
to30 */6 * * *
and it may work for you.if possible check the order time that didt applied discount and you may need to find what is exact timings that price rules are not working. Temparary fix is clicking "Apply catalog rules " button again when it was not working.