How to Implement Abandoned Cart in Magento 2?
The concept of abandoned cart email in Magento 2 is to grow the e-commerce business efficiently. So, The main function of an abandoned cart is to remind the customers via email if they leave any items in the cart.
Here is the below code to implement Abandoned cart in Magento 2
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $collection = $objectManager->get('Magento\Reports\Model\ResourceModel\Quote\Collection'); $store_id = $objectManager->create('\Magento\Store\Model\StoreManager')->getStore()->getId(); $collection->prepareForAbandonedReport([$store_id]); $rows = $collection->load(); foreach($rows as $rowcolection){ $customer_name=$rowcolection->getCustomerFirstname(); $c?ustomerId=$rowcolection->getCustomerId(); $quote= $this->quoteFactory->create()->loadByCustomer($c?ustomerId); $quoteItems=$quote->getAllItems(); foreach($quoteItems as $oneItem){ $product_id=$oneItem->getProductId(); $product_name=$oneItem->getName(); } }
Conclusion:
We can apply this on Magento development. Please share your reviews in the comment section.
Comments