Skip to content

Commit 5bdffac

Browse files
author
Ganin, Roman(rganin)
committed
Merge pull request #321 from magento-troll/MAGETWO-37836
[Troll] Bug fix
2 parents 7ad03d2 + dd26383 commit 5bdffac

File tree

2 files changed

+27
-0
lines changed
  • app/code/Magento/Reports/Model/Resource/Quote
  • dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned

2 files changed

+27
-0
lines changed

app/code/Magento/Reports/Model/Resource/Quote/Collection.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,30 @@ protected function getCustomerNames($select)
166166
);
167167
return $select;
168168
}
169+
170+
/**
171+
* Add customer data
172+
*
173+
* @param array|null $filter
174+
* @return $this
175+
*/
176+
public function addCustomerData($filter = null)
177+
{
178+
$customersSelect = $this->customerResource->getReadConnection()->select();
179+
$customersSelect->from(['customer' => $this->getTable('customer_entity')], 'entity_id');
180+
if (isset($filter['customer_name'])) {
181+
$customersSelect = $this->getCustomerNames($customersSelect);
182+
$customerName = $customersSelect->getAdapter()->getConcatSql(['cust_fname.value', 'cust_lname.value'], ' ');
183+
$customersSelect->where(
184+
$customerName . ' LIKE ?',
185+
'%' . $filter['customer_name'] . '%'
186+
);
187+
}
188+
if (isset($filter['email'])) {
189+
$customersSelect->where('customer.email LIKE ?', '%' . $filter['email'] . '%');
190+
}
191+
$filteredCustomers = $this->customerResource->getReadConnection()->fetchCol($customersSelect);
192+
$this->getSelect()->where('main_table.customer_id IN (?)', $filteredCustomers);
193+
return $this;
194+
}
169195
}

dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/GridTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function testGridContent()
2626
$layout = Bootstrap::getObjectManager()->get('Magento\Framework\View\LayoutInterface');
2727
/** @var Grid $grid */
2828
$grid = $layout->createBlock('Magento\Reports\Block\Adminhtml\Shopcart\Abandoned\Grid');
29+
$grid->getRequest()->setParams(['filter' => base64_encode(urlencode('email=customer@example.com'))]);
2930
$result = $grid->getPreparedCollection();
3031

3132
$this->assertCount(1, $result->getItems());

0 commit comments

Comments
 (0)