When looking at sales_flat_quote (M1) or quote (M2) table, there are many quotes stuck at is_active=1. Even though there is a sale in sales_flat_order / sales_order.
This does not seem to have a relation to the state of the order (finding complete/processing/canceled orders), nor payment method (finding paypal, checkmo and 3rd party gateway orders).
When joining the quote and sales tables to find orders with 'open' quotes, I find many results on several shops that we manage.
I'm using this query on M1:
SELECT `sales_flat_order`.`state`,
`sales_flat_order`.`increment_id`,
`sales_flat_order`.`entity_id`,
`sales_flat_order`.`created_at`,
`sales_flat_order`.`quote_id`,
`sales_flat_quote`.`is_active`,
`sales_flat_quote`.`customer_email`,
`sales_flat_order_payment`.`method`
FROM `sales_flat_order`
LEFT JOIN sales_flat_quote ON `sales_flat_order`.`quote_id`=`sales_flat_quote`.`entity_id`
LEFT JOIN `sales_flat_order_payment` ON sales_flat_order.`entity_id`=sales_flat_order_payment.`parent_id`
WHERE `sales_flat_quote`.`is_active` = 1;
and this one on M2:
SELECT `sales_order`.`state`,
`sales_order`.`increment_id`,
`sales_order`.`entity_id`,
`sales_order`.`created_at`,
`sales_order`.`quote_id`,
`quote`.`is_active`,
`quote`.`customer_email`,
`sales_order_payment`.`method`
FROM `sales_order`
LEFT JOIN quote ON `sales_order`.`quote_id`=`quote`.`entity_id`
LEFT JOIN `sales_order_payment` ON sales_order.`entity_id`=sales_order_payment.`parent_id`
WHERE `quote`.`is_active` = 1;
Am I looking at this the wrong way? Can people confirm the same thing for their M1/M2 shop?
Best Answer
I can confirm that there are a large number of returned rows on several stores that I have access to for your Magento 1 query above. These don't seem to be related with a specific payment method.
There are a number of reaons why the is_active flag is set to 0 or 1.
There are a number of reasons in the Magento flow why the is_active flag may remain at 1.
Mage/Sales/Model/Service/Quote.php
has a$_shouldInactivateQuote
flag which is checked against when the_inactivateQuote()
method is called duringsubmitOrder()
.This wouldn't allow the flag to be set to 0 if:
submitAll()
Additionally, there are a number of times in the codebase when the flag is specifically set to true (1).
Mage/Persistent/Model/Observer.php
-setQuoteGuest
- would be worth checking if these orders were completed as a guest by addingcustomer_id
to your query above.Mage/PayPal/Helper/Checkout.php
&Mage/Authorizenet/controllers/Directpost/PaymentController.php