File tree Expand file tree Collapse file tree 2 files changed +53
-1
lines changed
app/code/Magento/Reports/Model/ResourceModel/Review/Customer
dev/tests/integration/testsuite/Magento/Reports/Model/ResourceModel/Review/Customer Expand file tree Collapse file tree 2 files changed +53
-1
lines changed Original file line number Diff line number Diff line change @@ -103,20 +103,36 @@ protected function _joinCustomers()
103
103
return $ this ;
104
104
}
105
105
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
+
106
121
/**
107
122
* Get select count sql
108
123
*
109
124
* @return string
110
125
*/
111
126
public function getSelectCountSql ()
112
127
{
113
- $ countSelect = clone $ this ->_select ;
128
+ $ countSelect = clone $ this ->getSelect () ;
114
129
$ countSelect ->reset (\Magento \Framework \DB \Select::ORDER );
115
130
$ countSelect ->reset (\Magento \Framework \DB \Select::GROUP );
116
131
$ countSelect ->reset (\Magento \Framework \DB \Select::HAVING );
117
132
$ countSelect ->reset (\Magento \Framework \DB \Select::LIMIT_COUNT );
118
133
$ countSelect ->reset (\Magento \Framework \DB \Select::LIMIT_OFFSET );
119
134
$ countSelect ->reset (\Magento \Framework \DB \Select::COLUMNS );
135
+ $ countSelect ->reset (\Magento \Framework \DB \Select::WHERE );
120
136
121
137
$ countSelect ->columns (new \Zend_Db_Expr ('COUNT(DISTINCT detail.customer_id) ' ));
122
138
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ namespace Magento \Reports \Model \ResourceModel \Review \Customer ;
7
+
8
+ /**
9
+ * @magentoAppArea adminhtml
10
+ */
11
+ class CollectionTest extends \PHPUnit \Framework \TestCase
12
+ {
13
+ /**
14
+ * @var \Magento\Reports\Model\ResourceModel\Review\Customer\Collection
15
+ */
16
+ private $ collection ;
17
+
18
+ protected function setUp ()
19
+ {
20
+ $ this ->collection = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
21
+ \Magento \Reports \Model \ResourceModel \Review \Customer \Collection::class
22
+ );
23
+ }
24
+
25
+ /**
26
+ * This tests covers issue described in:
27
+ * https://github.com/magento/magento2/issues/10301
28
+ *
29
+ * @magentoDataFixture Magento/Review/_files/customer_review.php
30
+ */
31
+ public function testSelectCountSql ()
32
+ {
33
+ $ this ->collection ->addFieldToFilter ('customer_name ' , ['like ' => '%John% ' ])->getItems ();
34
+ $ this ->assertEquals (1 , $ this ->collection ->getSize ());
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments