@@ -244,7 +244,7 @@ public function sendAbandonedCartData($quoteId = null): array
244
244
if ($ quoteId ) {
245
245
$ abandonedCarts ->addFieldToFilter ('entity_id ' , ['eq ' => $ quoteId ]);
246
246
}
247
- $ abandonedCarts ->setPageSize ($ numberOfAbandonedCart );
247
+ $ abandonedCarts ->setPageSize ($ numberOfAbandonedCart )-> setOrder ( ' main_table.updated_at ' , " desc " ) ;
248
248
$ abandonedCarts ->getSelect ()->join (array ('address ' => $ abandonedCarts ->getResource ()->getTable ('quote_address ' )), 'main_table.entity_id = address.quote_id ' )
249
249
->where ("address.address_type='billing' and (main_table.customer_email is not null or address.email is not null) " );
250
250
foreach ($ abandonedCarts as $ abandonedCart ) {
@@ -288,7 +288,7 @@ public function sendAbandonedCartData($quoteId = null): array
288
288
"orderDiscounts " => [
289
289
"discountAmount " => $ this ->coreHelper ->priceToCents ($ abandonedCart ->getDiscountAmount ())
290
290
],
291
- "orderUrl " => $ this ->urlBuilder ->getDirectUrl ('checkout/cart ' ),
291
+ "orderUrl " => $ this ->urlBuilder ->setScope ( $ abandonedCart -> getStoreId ())-> getDirectUrl ('checkout/cart ' ),
292
292
"abandonedDate " => $ this ->dateTime ->date (strtotime ($ abandonedUpdateDate ),NULL ,$ timezone )->format ('Y-m-d\TH:i:sP ' ),
293
293
"externalCreatedDate " => $ this ->dateTime ->date (strtotime ($ abandonedCartRepository ->getCreatedAt ()),NULL ,$ timezone )->format ('Y-m-d\TH:i:sP ' ),
294
294
"externalUpdatedDate " => $ this ->dateTime ->date (strtotime ($ abandonedUpdateDate ),NULL ,$ timezone )->format ('Y-m-d\TH:i:sP ' ),
@@ -361,17 +361,26 @@ public function sendAbandonedCartData($quoteId = null): array
361
361
*/
362
362
private function getQuoteItemsData ($ entityId , $ storeId ): array
363
363
{
364
+
364
365
$ quoteItemsData = [];
366
+ $ this ->appEmulation ->startEnvironmentEmulation ($ storeId , Area::AREA_FRONTEND , true );
365
367
$ quoteItems = $ this ->getQuoteItems ($ entityId );
366
368
foreach ($ quoteItems as $ quoteItem ) {
367
- $ this -> appEmulation -> startEnvironmentEmulation ( $ storeId , Area:: AREA_FRONTEND , true );
369
+
368
370
369
371
$ product = $ this ->_productRepositoryFactory ->create ()
370
- ->getById ($ quoteItem ->getProductId ());
372
+ ->getById ($ quoteItem ->getProductId (), false , $ storeId );
371
373
372
374
$ imageUrl = $ this ->imageHelperFactory ->create ()
373
375
->init ($ product , 'product_page_image_medium ' )->getUrl ();
374
376
$ this ->appEmulation ->stopEnvironmentEmulation ();
377
+ $ categories = $ product ->getCategoryCollection ()->addAttributeToSelect ('name ' );
378
+ $ categoriesName = [];
379
+ foreach ($ categories as $ category )
380
+ {
381
+ $ categoriesName [] = $ category ->getName ();
382
+ }
383
+ $ categoriesName = implode (', ' , $ categoriesName );
375
384
$ quoteItemsData [] = [
376
385
"externalid " => $ quoteItem ->getItemId (),
377
386
"name " => $ quoteItem ->getName (),
@@ -380,7 +389,8 @@ private function getQuoteItemsData($entityId, $storeId): array
380
389
"sku " => $ quoteItem ->getSku (),
381
390
"description " => $ product ->getDescription (),
382
391
"imageUrl " => $ imageUrl ,
383
- "productUrl " => $ product ->getProductUrl ()
392
+ "productUrl " => $ product ->getProductUrl (),
393
+ "category " => $ categoriesName
384
394
];
385
395
}
386
396
return $ quoteItemsData ;
0 commit comments