Question

I am looking for a table in the database where the Abandoned Carts are saved, but I cannot find the correct place. Where are the Abandoned Carts saved in the database? Or are they saved in a different matter (for example by combining data)?

Was it helpful?

Solution

There is no specific table that holds this data, this is the default SQL query which Magento will use to find abandoned carts.

SELECT
  `main_table`.*,
  (main_table.base_subtotal_with_discount * main_table.base_to_global_rate) AS `subtotal`,
  `cust_email`.`email`,
  `cust_fname`.`value`                                                      AS `firstname`,
  `cust_lname`.`value`                                                      AS `lastname`,
  CONCAT_WS(' ', cust_fname.value, cust_lname.value)                        AS `customer_name`
FROM `sales_flat_quote` AS `main_table`
  INNER JOIN `customer_entity` AS `cust_email` ON cust_email.entity_id = main_table.customer_id
  INNER JOIN `customer_entity_varchar` AS `cust_fname`
    ON cust_fname.entity_id = main_table.customer_id AND cust_fname.attribute_id = 5
  INNER JOIN `customer_entity_varchar` AS `cust_lname`
    ON cust_lname.entity_id = main_table.customer_id AND cust_lname.attribute_id = 7
WHERE (items_count != '0') AND (main_table.is_active = '1');

In case you weren't aware, you can find this data by going into the admin panel under Reports > Shopping Bag > Abandoned Shopping Bags.

OTHER TIPS

You can simply use:

    $collection = Mage::getResourceModel('reports/quote_collection');
    $collection->prepareForAbandonedReport(array());
    echo '<pre>';
    print_r($collection->getData());// will print all abandoned carts.
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top