Magento CE 1.8.0 and 1.8.1 Special Price Bug: Symptoms, Cause, and Solutions
The Magento Community Edition (CE) versions 1.8.0 and 1.8.1 introduced a few notable bugs related to special pricing functionality. This post aims to provide a comprehensive overview of the issue, its root cause, and practical solutions for e-commerce merchants and developers.
The Special Price Bug in Magento CE 1.8.x
The primary symptom reported by users is that setting a product’s special price automatically populates the Set Product as New from Date (news_from_date), Special Price From Date (special_from_date), and Active From (custom_design_from) fields with the current date. Once these dates are set, they become immutable; you will be unable to remove them via either the admin panel or programmatically.
This issue was not present in earlier versions like Magento CE 1.7.2, making it a significant regression introduced in version 1.8.0 and subsequently carried over to 1.8.1 releases.
Root Cause Analysis
The root cause of this bug lies in the core logic of Magento’s product price saving process, specifically in the Mage_Catalog_Model_Product class. The issue stems from an incorrect conditional check during the special price update flow.
Here is a simplified snippet from the affected method (the actual line numbers have been omitted for brevity):
public function save()
{
// ... existing code ...
if ($this->getSpecialPrice()) {
$this->setNewsFromDate(date('Y-m-d H:i:s'));
$this->setSpecialFromDate($this->getSpecialPriceToDate());
$this->setCustomDesignFromDate($this->getSpecialPriceFromDate());
}
// ... remaining code ...
}
The logic incorrectly sets the news_from_date, special_from_date, and custom_design_from values regardless of whether the special price was actually modified. This leads to the dates being set even when no changes are made, causing the issue described earlier.
Practical Solutions for Merchants and Developers
For Magento CE 1.8.0 and 1.8.1 Users
If you’re currently using versions 1.8.0 or 1.8.1, your best course of action is to upgrade to a later stable release that has addressed this issue. Magento CE version 1.9.x (and later) includes hotfixes for various bugs present in the 1.8.x series.
You can find more information about the upgrade process and available versions on Laravel Company’s Magento Upgrade Guide.
For Developers: Hotfix Method
If you’re a developer working with an existing 1.8.x installation that cannot be easily upgraded, you can apply a hotfix by modifying the core Mage_Catalog_Model_Product class directly.
First, make sure to take a complete backup of your codebase and database before proceeding with any changes.
Next, update the save() method in the Mage_Catalog_Model_Product file as follows:
public function save()
{
// ... existing code ...
if ($this->getIsChanged('special_price')) {
$this->setNewsFromDate(date('Y-m-d H:i:s'));
$this->setSpecialFromDate($this->getSpecialPriceToDate());
$this->setCustomDesignFromDate($this->getSpecialPriceFromDate());
} else {
$this->setNewsFromDate(null);
$this->setSpecialFromDate(null);
$this->setCustomDesignFromDate(null);
}
// ... remaining code ...
}
The updated logic checks whether the special price has actually changed before setting the dates. If no changes are made, it clears the values for news_from_date, special_from_date, and custom_design_from.
After implementing this hotfix, ensure that you have proper version control in place to track your changes and easily revert if needed.
Conclusion
The special price bug in Magento CE 1.8.0 and 1.8.1 is a clear example of how regression issues can arise during core functionality updates. Understanding the root cause allows developers to apply targeted hotfixes or, more importantly, encourages merchants to keep their platforms up-to-date with officially supported versions.
Always ensure you’re working with the latest stable release of Magento CE for optimal performance and security. If you require assistance with Magento upgrades or need expert guidance on custom development, feel free to reach out to our team at Laravel Company.