File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -166,4 +166,30 @@ protected function getCustomerNames($select)
166
166
);
167
167
return $ select ;
168
168
}
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
+ }
169
195
}
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ public function testGridContent()
26
26
$ layout = Bootstrap::getObjectManager ()->get ('Magento\Framework\View\LayoutInterface ' );
27
27
/** @var Grid $grid */
28
28
$ grid = $ layout ->createBlock ('Magento\Reports\Block\Adminhtml\Shopcart\Abandoned\Grid ' );
29
+ $ grid ->getRequest ()->setParams (['filter ' => base64_encode (urlencode ('email=customer@example.com ' ))]);
29
30
$ result = $ grid ->getPreparedCollection ();
30
31
31
32
$ this ->assertCount (1 , $ result ->getItems ());
You can’t perform that action at this time.
0 commit comments