blog site of branko ajzele, senior developer / project manager

Undefined index year in Date.php on line 2614

The other day I came across this little bug in Magento 1.1.6. After setting the products special price and clicking Save and continue Edit, then after adding some additional input to product and clicking the Save and continue Edit i got the following error Undefined index year… in Date.php on line 2614.

If you look at the screenshot you can see that there is a bug on the Prices tab, where upon each Save and continue Edit, Magento does not pool the year value into the Special Price From Date and Special Price to Date fields. Its missing the middle year value. So basically what you need to do is to set it up upon each Save and continue Edit.

  • Eu
    The bug is caused by locale settings and it appears only when you use a certain date format, for example the US standard format(mm/dd/yyyy) triggers it. Namitha's modification seems to fix it. Tnx
  • Namitha
    ../magento/app/code/core/Mage/Core/Model/Locale.php lines 379 to 381. Change the following:

    $convert = array('yyyy-MM-ddTHH:mm:ssZZZZ'=>'%c', 'EEEE'=>'%A', 'EEE'=>'%a','D'=>'%j',
    'MMMM'=>'%B', 'MMM'=>'%b', 'MM'=>'%m', 'M'=>'%m', 'dd'=>'%d',
    'd'=>'%e', 'yyyy'=>'%Y', 'yy'=>'%y');

    to the folowing code:

    $convert = array('yyyy-MM-ddTHH:mm:ssZZZZ'=>'%c', 'EEEE'=>'%A', 'EEE'=>'%a','D'=>'%j',
    'MMMM'=>'%B', 'MMM'=>'%b', 'MM'=>'%m', 'M'=>'%m', 'dd'=>'%d',
    'd'=>'%d', 'yyyy'=>'%Y', 'yy'=>'%y');

    Note the ā€˜d’=>’%d’ in the third line of code makes all the difference. Now, all your dates will work properly now.
  • Mike
    Looks like somebody reported the issue here:

    http://www.magentocommerce.com/bug-tracking/iss...

    but the Magento team was unable to reproduce it so they closed the ticket. I'm not sure why they considered it "Resolved", though. I'm still experiencing the problem in 1.1.6.
  • Thank you for this. I looked all over Magento's horrible forums and couldn't find any mention of this. There were other references to this error related to mismatched local settings, but that wasn't my case.
  • Magelover
    Yeah, that's a very annoying bug...hope they fix it for the next release
blog comments powered by Disqus
Powered by Wordpress | Designed by Elegant Themes