I am able to change Catalog Price Rules' from_date and to_date from "date" datatype into "datetime", by overriding the classes:

  • Mage_Adminhtml_Block_Promo_Catalog_Edit_Tab_Main
  • Mage_Adminhtml_Promo_CatalogController
  • Mage_CatalogRule_Model_Rule

and changing the datatype of the table columns catalogrule.from_date and catalogrule.to_date into "datetime".

Is doing the latter safe? Or should I somehow create or modify some files, maybe in an sql folder somewhere, e.g. my module's? Or could anyone point me to some resources I can peruse to achieve such? I just want to do this properly.


You can change it manually but then you have to change it on your every Magento instance. (staging, live).
The safest way to do it is to create a module (use the same module that holds the class rewrites) and include in your module an upgrade script that changes the column.
Something like this:

ALTER TABLE `{$this->getTable('catalogrule/rule')}` CHANGE `from_date` `from_date` DATETIME NULL DEFAULT NULL
ALTER TABLE `{$this->getTable('catalogrule/rule')}` CHANGE `to_date` `to_date` DATETIME NULL DEFAULT NULL

This way you can make your changes portable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.