Skip to content

Filter Group Builder OR doesn't work only AND works #8300

@ghost

Description

Filter Group Builder OR doesn't work only AND works.
Its wrong according to the Docs here
http://devdocs.magento.com/guides/v2.1/howdoi/webapi/search-criteria.html
screen shot 2017-01-26 at 4 21 20 pm

        $productFilters[] = $this->filterBuilder->setField('sku')
          ->setValue('%'.$productSearch.'%')
          ->setConditionType('like')
          ->create();

        $productFilters[] = $this->filterBuilder->setField('name')
          ->setValue('%'.$productSearch.'%')
          ->setConditionType('like')
          ->create();

        $filter_group_products = $this->filterGroup
          ->setFilters($productFilters)
          ->create();

        $searchCriteriaProducts = $this->searchCriteriaBuilder
                      ->setFilterGroups([$filter_group_products])
                      ->create();

        $listProducts = $this->orderItemRepository->getList($searchCriteriaProducts);

makes this query with a AND

SELECT `main_table`.* FROM `sales_order_item` AS `main_table` WHERE (`sku` LIKE '%80705%') AND (`name` LIKE '%80705%')

According to your docs is should make this with a OR

SELECT `main_table`.* FROM `sales_order_item` AS `main_table` WHERE (`sku` LIKE '%80705%') OR (`name` LIKE '%80705%')

Preconditions

  1. Magento 2.1.3
  2. PHP 7.1w
  3. Percona 5.6

Steps to reproduce

  1. Call the first example above.
  2. Look at query in mysql work bench
  3. No data gets pulled because its using a AND

Expected result

    1. Data should get pulled because it's using a OR

Actual result

  1. [Screenshot, logs]
    screen shot 2017-01-26 at 4 18 23 pm
    screen shot 2017-01-26 at 4 18 16 pm
    screen shot 2017-01-26 at 4 17 59 pm
    screen shot 2017-01-26 at 4 21 20 pm

@igrybkov I think this has something to do with your update on
19d8137

Metadata

Metadata

Labels

Component: SalesFixed in 2.1.xThe issue has been fixed in 2.1 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentbug report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions