Skip to content

Commit 05bb680

Browse files
Merge pull request #1626 from magento-engcom/2.1-develop-prs
[EngCom] Public Pull Requests - 2.1-develop - MAGETWO-82178 Fix Filter Customer Report Review 2.1-develop [Backport] #11523 - MAGETWO-82762 [Backport 2.1-develop] Dashboard Fix Y Axis for range #11753
2 parents 619ac30 + 6f18d0d commit 05bb680

File tree

3 files changed

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

3 files changed

+56
-2
lines changed

app/code/Magento/Backend/Block/Dashboard/Graph.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ public function getChartUrl($directUrl = true)
421421
$tmpstring = implode('|', $this->_axisLabels[$idx]);
422422

423423
$valueBuffer[] = $indexid . ":|" . $tmpstring;
424+
} elseif ($idx == 'y') {
425+
$valueBuffer[] = $indexid . ":|" . implode('|', $yLabels);
424426
}
425427
$indexid++;
426428
}

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

Lines changed: 18 additions & 2 deletions
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,20 +99,36 @@ 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
*
105120
* @return string
106121
*/
107122
public function getSelectCountSql()
108123
{
109-
$countSelect = clone $this->_select;
124+
$countSelect = clone $this->getSelect();
110125
$countSelect->reset(\Magento\Framework\DB\Select::ORDER);
111126
$countSelect->reset(\Magento\Framework\DB\Select::GROUP);
112127
$countSelect->reset(\Magento\Framework\DB\Select::HAVING);
113128
$countSelect->reset(\Magento\Framework\DB\Select::LIMIT_COUNT);
114129
$countSelect->reset(\Magento\Framework\DB\Select::LIMIT_OFFSET);
115130
$countSelect->reset(\Magento\Framework\DB\Select::COLUMNS);
131+
$countSelect->reset(\Magento\Framework\DB\Select::WHERE);
116132

117133
$countSelect->columns(new \Zend_Db_Expr('COUNT(DISTINCT detail.customer_id)'));
118134

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 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+
}

0 commit comments

Comments
 (0)