Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class KesharTechnosys_Datefix_Model_Entity_Attribute_Backend_Time_Created extends Mage_Eav_Model_Entity_Attribute_Backend_Time_Created
- {
- public function beforeSave($object)
- {
- $attributeCode = $this->getAttribute()->getAttributeCode();
- $date = $object->getData($attributeCode);
- if (is_null($date)) {
- if ($object->isObjectNew()) {
- $object->setData($attributeCode, Varien_Date::now());
- }
- } else {
- $date = strtotime($date);
- $zendDate = Mage::app()->getLocale()->utcDate(null, $date, true);
- $object->setData($attributeCode, $zendDate->getIso());
- }
- return $this;
- }
- public function afterLoad($object)
- {
- $attributeCode = $this->getAttribute()->getAttributeCode();
- $date = $object->getData($attributeCode);
- if (!is_null($date)) {
- $date = strtotime($date);
- }
- $zendDate = Mage::app()->getLocale()->storeDate(null, $date, true);
- $object->setData($attributeCode, $zendDate->getIso());
- parent::afterLoad($object);
- return $this;
- }
- }
- ?>
Add Comment
Please, Sign In to add comment