Skip to content

Commit 1694e02

Browse files
committed
MAGETWO-82179: Fix Filter Customer Report Review 2.2-develop [Backport]
- #11522
1 parent 3b7a9ab commit 1694e02

File tree

2 files changed

+16
-1
lines changed
  • app/code/Magento/Reports/Model/ResourceModel/Review/Customer
  • dev/tests/integration/testsuite/Magento/Reports/Model/ResourceModel/Review/Customer

2 files changed

+16
-1
lines changed

app/code/Magento/Reports/Model/ResourceModel/Review/Customer/Collection.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,21 @@ protected function _joinCustomers()
103103
return $this;
104104
}
105105

106+
/**
107+
* {@inheritdoc}
108+
*
109+
* Additional processing of 'customer_name' field is required, as it is a concat field, which can not be aliased.
110+
* @see _joinCustomers
111+
*/
112+
public function addFieldToFilter($field, $condition = null)
113+
{
114+
if ($field === 'customer_name') {
115+
$field = $this->getConnection()->getConcatSql(['customer.firstname', 'customer.lastname'], ' ');
116+
}
117+
118+
return parent::addFieldToFilter($field, $condition);
119+
}
120+
106121
/**
107122
* Get select count sql
108123
*

dev/tests/integration/testsuite/Magento/Reports/Model/ResourceModel/Review/Customer/CollectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected function setUp()
3030
*/
3131
public function testSelectCountSql()
3232
{
33-
$this->collection->addFieldToFilter('customer_name', ['like' => '%john%']);
33+
$this->collection->addFieldToFilter('customer_name', ['like' => '%John%'])->getItems();
3434
$this->assertEquals(1, $this->collection->getSize());
3535
}
3636
}

0 commit comments

Comments
 (0)