Reputation: 3165
How could I get all the abandoned carts with customer's email (programatically)?
What does Magento consider as being abandoned? Not updated in the last day?
Upvotes: 1
Views: 2294
Reputation: 2072
The admin section in Magento has this functionality built in. In the admin section visit Reports->Shopping Cart->Abandoned carts
.
This page contains an admin grid with all the abandoned carts and the customer email attached. It even gives you the standard export functionality so you can get a file in different formats containing all the information you need.
Upvotes: 2
Reputation: 1930
Standalone file that can be used anywhere you wish.
Either filter by is_active or check if any of your orders contain the quote id ( in which case the quote became an order so obviously not abandoned ).
require_once( 'app/Mage.php' );
umask(0);
Mage::app('default');
$sCustomerId = 1;
$oQuotes = Mage::getModel( 'sales/quote' )->getCollection();
$oQuotes->addFieldToFilter( 'customer_id', $sCustomerId );
foreach( $oQuotes as $oQuote )
{
var_dump( $oQuote->getData( 'is_active' ) );
$oOrders = Mage::getModel( 'sales/order' )->getCollection();
$oOrders->addFieldToFilter( 'quote_id', $oQuote->getId() );
var_dump( 'Became an order?: ' );
var_dump( $oOrders->count() );
$oItems = Mage::getModel( 'sales/quote_item' )
->getCollection()
->setQuote( $oQuote );
foreach( $oItems as $oItem )
{
var_dump( $oItem->getProduct()->getId() );
}
}
Upvotes: 2
Reputation: 14746
This link will give your all answers abondoned cart. Hope this will helpful to you.
Upvotes: 0