Skip to content

Commit

Permalink
Merge pull request #321 from magento-troll/MAGETWO-37836
Browse files Browse the repository at this point in the history
[Troll] Bug fix
  • Loading branch information
Ganin, Roman(rganin) committed May 25, 2015
2 parents 7ad03d2 + dd26383 commit 5bdffac
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions app/code/Magento/Reports/Model/Resource/Quote/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,30 @@ protected function getCustomerNames($select)
);
return $select;
}

/**
* Add customer data
*
* @param array|null $filter
* @return $this
*/
public function addCustomerData($filter = null)
{
$customersSelect = $this->customerResource->getReadConnection()->select();
$customersSelect->from(['customer' => $this->getTable('customer_entity')], 'entity_id');
if (isset($filter['customer_name'])) {
$customersSelect = $this->getCustomerNames($customersSelect);
$customerName = $customersSelect->getAdapter()->getConcatSql(['cust_fname.value', 'cust_lname.value'], ' ');
$customersSelect->where(
$customerName . ' LIKE ?',
'%' . $filter['customer_name'] . '%'
);
}
if (isset($filter['email'])) {
$customersSelect->where('customer.email LIKE ?', '%' . $filter['email'] . '%');
}
$filteredCustomers = $this->customerResource->getReadConnection()->fetchCol($customersSelect);
$this->getSelect()->where('main_table.customer_id IN (?)', $filteredCustomers);
return $this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function testGridContent()
$layout = Bootstrap::getObjectManager()->get('Magento\Framework\View\LayoutInterface');
/** @var Grid $grid */
$grid = $layout->createBlock('Magento\Reports\Block\Adminhtml\Shopcart\Abandoned\Grid');
$grid->getRequest()->setParams(['filter' => base64_encode(urlencode('[email protected]'))]);
$result = $grid->getPreparedCollection();

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

0 comments on commit 5bdffac

Please sign in to comment.