Skip to content

Commit bc6c5ac

Browse files
committed
#11523: Fix Filter Customer Report Review
- Integration test updated - Added backport for MAGETWO-53296 to 2.1, as it blocked the flow
1 parent b513e51 commit bc6c5ac

File tree

2 files changed

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

2 files changed

+17
-2
lines changed

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected function _joinCustomers()
8383
$this->getSelect()->reset(
8484
\Magento\Framework\DB\Select::COLUMNS
8585
)->joinInner(
86-
['customer' => $connection->getTableName('customer_entity')],
86+
['customer' => $this->getTable('customer_entity')],
8787
'customer.entity_id = detail.customer_id',
8888
[]
8989
)->columns(
@@ -99,6 +99,21 @@ protected function _joinCustomers()
9999
return $this;
100100
}
101101

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

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)