Magento customer account backup

I am trying to update a DOBclient from a magnet backend. The year of the DOB I'm going to set is 1967. Good. Well, the record has been updated successfully, but when I go into the database table and see the DOB, it contains the year 2067. I am surprised how this happened.

I went back into the backend and installed it in 1971 and updated the client record. But this time, the DOB is in the database table. This is the year 1971.

I came to the conclusion that DOB less than 1970 is stored incorrectly in the database.

Is it a magento bug or something is wrong with my copy of magento.

thank

+3
source share
2 answers

Magento, , ​​ 1.5.0.0. .

, EAV Customer. 1) backend YYYY YY

2) , DOB
3) "date" ( customer_eav_attribute)


2) , _dateFilterFormat 'dob'

+3

1.5.1 . , , . , , :

  • \code\core\Mage\Adminhtml\Block\Widget\Form.php _setFieldset, "FORMAT_TYPE_MEDIUM"

    if($attribute->getName() == 'dob') $element->setFormat(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM));
    
  • \code\core\Mage\Customer\Model\Attribute\Data\Abstract.php _dateFilterFormat is_null ($ format)

    $a = $this->getAttribute();
    if(!empty($a) && $a->getName() == 'dob') {
        $this->_dateFilterFormat = Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM;
        return Mage::app()->getLocale()->getDateFormat($this->_dateFilterFormat);
    }
    
  • app\code\core\Mage\Customer\Block\Widget\Dob.php getDateFormat FORMAT_TYPE_MEDIUM . JavaScript - , "y", , " " ( "Date" ), . , 1901 .

    , ( 1.5.1) js\varien\js.js DateElement.validate, < 1900, ! this.validateData. , , DOB, :

    Varien.DOB = Class.create();
    Varien.DOB.prototype = {
      initialize: function(selector, required, format) {
        var el = $$(selector)[0];
        var container       = {};
        container.day       = Element.select(el, '.dob-day input')[0];
        container.month     = Element.select(el, '.dob-month input')[0];
        container.year      = Element.select(el, '.dob-year input')[0];
        container.full      = Element.select(el, '.dob-full input')[0];
        container.advice    = Element.select(el, '.validation-advice')[0];
    
        this.child = new Varien.DateElement('container', container, required, format);
    
        container.day.validate = this.validate.bind(this);
        container.month.validate = this.validate.bind(this);
        container.year.validate = this.validate.bind(this);
      },
      validate: function() {
         if(this.child.validate()) {
           var year = parseInt(this.child.year.value, 10);
           if (!isNaN(year) && (year<1900 || year>this.child.curyear) ) {
                errorType = this.child.validateDataErrorType;
                valueError = this.child.validateDataErrorText;
                error = valueError;
                try {
                    error = Translator.translate(error);
                }
                catch (e) {}
                this.child.advice.innerHTML = this.child.errorTextModifier(error);
                this.child.advice.show();
                return false;
           }
           return true;
        }
        return false;
      },
    };
    
  • , Magento DOB 13 1901 , strtotime. app\code\core\Mage\Customer\Block\Widget\Dob.php:

        public function setDate($date)
        {
            $this->setTime($date ? strtotime($date) : false);
            $this->setData('date', $date);
            try {
                $this->setDateTime(new DateTime($date));
            }catch(Exception $e){}
    
            return $this;
        }
    
        public function getDay()
        {
            return $this->getTime() ? date('d', $this->getTime()) : ($this->getDateTime() ? $this->getDateTime()->format('d') : '');
        }
    
        public function getMonth()
        {
            return $this->getTime() ? date('m', $this->getTime()) : ($this->getDateTime() ? $this->getDateTime()->format('m') : '');
        }
    
        public function getYear()
        {
            return $this->getTime() ? date('Y', $this->getTime()) : ($this->getDateTime() ? $this->getDateTime()->format('Y') : '');
        }
    

, ... ;).

+2

Source: https://habr.com/ru/post/1782057/


All Articles