magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Bug in Widget condition filter for price range - Error filtering template: Unknown condition operator #13736

Closed magefast closed 5 years ago

magefast commented 6 years ago

Exist error/bug in conditions filter. Not working conditions for price (or other numeric type) - less than, more than, etc.

As I understand - problem is - when saved type of filter like - '>=', '>', '<=', '<' - converted to HTML entities. (https://dev.w3.org/html5/html-author/charref)

Preconditions

  1. Magento version - 2.2.2
  2. PHP Version 7.0.22-0ubuntu0.16.04.1 , default_charset - UTF-8

Steps to reproduce

  1. Create widget for Homepage, product list, conditions - product price from 1$
  2. Check Homepage, you will see - Error filtering template: Unknown condition operator

Expected result

  1. Will show list of products with filter in conditions.

How to fix

in file app/code/Magento/Rule/Model/Condition/Sql/Builder.php need update array - protected $_conditionOperatorMap

add followings:

        '&gt;=' => ':field >= ?',
        '&gt;'  => ':field > ?',
        '&lt;=' => ':field <= ?',
        '&lt;'  => ':field < ?',

and final protected $_conditionOperatorMap like -

protected $_conditionOperatorMap = [
        '=='    => ':field = ?',
        '!='    => ':field <> ?',
        '>='    => ':field >= ?',
        '>'     => ':field > ?',
        '<='    => ':field <= ?',
        '<'     => ':field < ?',
        '{}'    => ':field IN (?)',
        '!{}'   => ':field NOT IN (?)',
        '()'    => ':field IN (?)',
        '!()'   => ':field NOT IN (?)',
        '&gt;=' => ':field >= ?',
        '&gt;'  => ':field > ?',
        '&lt;=' => ':field <= ?',
        '&lt;'  => ':field < ?',
    ];

Resume

Maybe this settings of PHP, but installed standard PHP version without extra settings.

Thanks

jidjijdi

home_page___pages___elements___content___magento_admin

magento-engcom-team commented 6 years ago

@magefast, thank you for your report. We've acknowledged the issue and added to our backlog.

sydekumf commented 6 years ago

Hey there, the same problem also occurs for Magento 2.1, the serialized value looks like this: s:1:"&gt;"; which of course can not be deserialized. Any idea when this will be fixed? :wink:

axovel commented 6 years ago

Any updates on this ? I am also getting the same issue

Mobecls commented 6 years ago

In this situation, I just changed the '& gt;' on '>' in the widget code.

magento-engcom-team commented 5 years ago

Hi @vasilii-b. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if your want to validate it one more time, please, go though the following instruction:

vasilii-b commented 5 years ago

Hi @magefast , Unfortunately I wasn't able to reproduce the issue on the 2.3-develop branch. Can you please re-check if issue still exists and reopen it if so ? Thank you!