Magento2: Exception Error in Catalog Price Rule while Backend language is not English

Created on 22 Nov 2017  Â·  23Comments  Â·  Source: magento/magento2


Preconditions


  1. Magento 2.2.1, Php 7, Mysql 5.6
  2. Interface Backend Magento language SET to Italy.

Steps to reproduce

  1. Go to: Marketing -> catalog price rule
  2. Edit a record already created
  3. Click on "Save and Apply"

Expected result


1. The following message:
- We found updated rules that are not applied. Please click "Apply Rules" to update your catalog.
- You saved the rule.

Actual result

  1. Error message that say that "something got wrong, check the log". (See the image attached)

Error detailed from exception.log:
main.CRITICAL: DateTime::__construct(): Failed to parse time string (22/11/2017) at position 0 (2): Unexpected character {"exception":"[object] (Exception(code: 0): DateTime::__construct(): Failed to parse time string (22/11/2017) at position 0 (2): Unexpected character at /home/zboutiqf/public_html/nuovo_magento/vendor/magento/module-rule/Model/AbstractModel.php:399)"} []

IMPORTANT:
With Backend language set to English the error does not occur, only with Italian language.

schermata 2017-11-22 alle 13 13 42

squashtoberfest Fixed in 2.2.x Fixed in 2.3.x Clear Description Confirmed Format is valid Reproduced on 2.2.x Reproduced on 2.3.x

All 23 comments

@Drakas thank you for your report.
We were not able to reproduce this issue by following the steps you provided. Please provide more detailed steps to reproduce or try to reproduce this issue on a clean installation.

Same problem with french language here, on Magento 2.2.0 , Php 7, Mysql 5.6
I am able to create basket price rules however

Someone had the same problem 1 year ago

Apparently it can be because magento need a date filter to convert the localized date to an internal date "dd/MM/y" instead of "M/d/yy"

I can confirm it is because the date format, I am able to register a new rule in french language if I set it to an MM/DD/YY format (that's why we couldn't do it for black friday @Drakas)

Same problem in M2.2.2 with italian localization... it's a very annoying issue because we need to launch our website asap and this issue is currently blocking it!

Same problem here. Magento 2.2.3, Italian localization. Currently working on it.

seriously, we have some ecommerce to publish and no one has yet made a backport for version 2.2 (besides the fact that nobody knows when the 2.3 will be released)

I'm resolving with a plugin to reformat dates before they get to the method that throws the exception. Frankly I think this is a poor fix, but gets the job done and that's better than nothing until we get a better one. If I manage to fix this I'll post some code here.

Comment edited

Yesterday I published a quick fix in this comment but it wasn't helping much. I think you should try with this: https://github.com/Magonex/module-datetime

Other issues that seem to be related can be found here:
https://github.com/magento/magento2/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+Invalid+input+datetime+format+of+value

I found a solution, please try to follow this fix:
https://github.com/magento/magento2/pull/11306
and then change
/vendor/magento/module-catalog-rule/Controller/Adminhtml/Promo/Catalog/Save.php
adding this lines after line 62

`
$filterValues = ['from_date' => $this->_dateFilter];

            if ($this->getRequest()->getParam('to_date')) {
                $filterValues['to_date'] = $this->_dateFilter;
            }

            $inputFilter = new \Zend_Filter_Input(
                    $filterValues,
                    [],
                    $data
                    );

            $data = $inputFilter->getUnescaped();

`

these lines are present in module-sales-rule but not in module-catalog-rule

Still seeing the issue in 2.2.3 when user is set to British English.

@magento-engcom-team

Based on @Cristiano81 comment i created this patch that you can apply until this is resolved:
https://gist.github.com/LucaGallinari/f476c5383a7eeafdfe778c8a980902df

@LucaGallinari 'spatch is working fine, @magento-engcom-team it's possibile to include it in 2.2.7 release?

Would be fantastic

Il giorno 21 set 2018, alle ore 11:14, Cristian Sedaboni notifications@github.com ha scritto:

@LucaGallinari 'spatch is working fine, @magento-engcom-team it's possibile to include it in 2.2.7 release?

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

squashtoberfest

@Mardl thank you for joining. Please accept team invitation here and self-assign the issue.

@magento-engcom-team give me 2.3-develop instance

Hi @larsroettig. Thank you for your request. I'm working on Magento 2.3-develop instance for you

Hi @larsroettig, here is your Magento instance.
Admin access: https://i-12399-2-3-develop.engcom.dev.magento.com/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

Error can reproduce in 2.3 vanilla Instance is not fixed in 2.3

https://www.youtube.com/watch?v=xBMxMfKHmuc&feature=youtu.be

Hi @Drakas. Thank you for your report.
The issue has been fixed in magento/magento2#18419 by @Mardl in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.1 release.

Hi @Drakas. Thank you for your report.
The issue has been fixed in magento/magento2#19074 by @Mardl in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming 2.2.8 release.

Was this page helpful?
0 / 5 - 0 ratings