Guest User

Untitled

a guest
Dec 21st, 2016
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. <?php
  2. class KesharTechnosys_Datefix_Model_Entity_Attribute_Backend_Time_Created extends Mage_Eav_Model_Entity_Attribute_Backend_Time_Created
  3. {
  4.  
  5. public function beforeSave($object)
  6. {
  7. $attributeCode = $this->getAttribute()->getAttributeCode();
  8. $date = $object->getData($attributeCode);
  9. if (is_null($date)) {
  10. if ($object->isObjectNew()) {
  11. $object->setData($attributeCode, Varien_Date::now());
  12. }
  13. } else {
  14. $date = strtotime($date);
  15.  
  16. $zendDate = Mage::app()->getLocale()->utcDate(null, $date, true);
  17. $object->setData($attributeCode, $zendDate->getIso());
  18. }
  19.  
  20. return $this;
  21. }
  22.  
  23.  
  24. public function afterLoad($object)
  25. {
  26. $attributeCode = $this->getAttribute()->getAttributeCode();
  27. $date = $object->getData($attributeCode);
  28.  
  29. if (!is_null($date)) {
  30. $date = strtotime($date);
  31. }
  32.  
  33. $zendDate = Mage::app()->getLocale()->storeDate(null, $date, true);
  34. $object->setData($attributeCode, $zendDate->getIso());
  35.  
  36. parent::afterLoad($object);
  37.  
  38. return $this;
  39. }
  40. }
  41. ?>
Add Comment
Please, Sign In to add comment