Magento 1: Check if customer has quote
-
23-01-2021 - |
Question
How can I filter customers by the fact if they have a quote in the sales_flat_quote
table? I could foreach
every customer to check if their email address is located in the sales_flat_quote
table, but that doesn't sound like a good way to do it.
Solution
You can filter that table with its corresponding collection model:
$quote = Mage::getResourceModel('sales/quote_collection')
->addAttributeToFilter('customer_id', $customer->getId())
->addAttributeToFilter('is_active', 1)
->getFirstItem();
if($quote) {
//customer has quote
}
You only need the customer ID.
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange