@@ -244,7 +244,7 @@ public function sendAbandonedCartData($quoteId = null): array
244244 if ($ quoteId ) {
245245 $ abandonedCarts ->addFieldToFilter ('entity_id ' , ['eq ' => $ quoteId ]);
246246 }
247- $ abandonedCarts ->setPageSize ($ numberOfAbandonedCart );
247+ $ abandonedCarts ->setPageSize ($ numberOfAbandonedCart )-> setOrder ( ' main_table.updated_at ' , " desc " ) ;
248248 $ abandonedCarts ->getSelect ()->join (array ('address ' => $ abandonedCarts ->getResource ()->getTable ('quote_address ' )), 'main_table.entity_id = address.quote_id ' )
249249 ->where ("address.address_type='billing' and (main_table.customer_email is not null or address.email is not null) " );
250250 foreach ($ abandonedCarts as $ abandonedCart ) {
@@ -288,7 +288,7 @@ public function sendAbandonedCartData($quoteId = null): array
288288 "orderDiscounts " => [
289289 "discountAmount " => $ this ->coreHelper ->priceToCents ($ abandonedCart ->getDiscountAmount ())
290290 ],
291- "orderUrl " => $ this ->urlBuilder ->getDirectUrl ('checkout/cart ' ),
291+ "orderUrl " => $ this ->urlBuilder ->setScope ( $ abandonedCart -> getStoreId ())-> getDirectUrl ('checkout/cart ' ),
292292 "abandonedDate " => $ this ->dateTime ->date (strtotime ($ abandonedUpdateDate ),NULL ,$ timezone )->format ('Y-m-d\TH:i:sP ' ),
293293 "externalCreatedDate " => $ this ->dateTime ->date (strtotime ($ abandonedCartRepository ->getCreatedAt ()),NULL ,$ timezone )->format ('Y-m-d\TH:i:sP ' ),
294294 "externalUpdatedDate " => $ this ->dateTime ->date (strtotime ($ abandonedUpdateDate ),NULL ,$ timezone )->format ('Y-m-d\TH:i:sP ' ),
@@ -361,13 +361,15 @@ public function sendAbandonedCartData($quoteId = null): array
361361 */
362362 private function getQuoteItemsData ($ entityId , $ storeId ): array
363363 {
364+
364365 $ quoteItemsData = [];
366+ $ this ->appEmulation ->startEnvironmentEmulation ($ storeId , Area::AREA_FRONTEND , true );
365367 $ quoteItems = $ this ->getQuoteItems ($ entityId );
366368 foreach ($ quoteItems as $ quoteItem ) {
367- $ this -> appEmulation -> startEnvironmentEmulation ( $ storeId , Area:: AREA_FRONTEND , true );
369+
368370
369371 $ product = $ this ->_productRepositoryFactory ->create ()
370- ->getById ($ quoteItem ->getProductId ());
372+ ->getById ($ quoteItem ->getProductId (), false , $ storeId );
371373
372374 $ imageUrl = $ this ->imageHelperFactory ->create ()
373375 ->init ($ product , 'product_page_image_medium ' )->getUrl ();
0 commit comments