Question

Does the sales/quote object work differently than other objects when loading? See the following..

Works:

$quote = Mage::getModel('sales/quote')->getCollection()
    ->addFieldToFilter('entity_id', $quoteId)
    ->getFirstItem();
print_r($quote->getData()); // shows right data

Does not work:

$quote = Mage::getModel('sales/quote')->load($quoteId);
print_r($quote->getData()); // empty

Both $quote are of the correct of class, Mage_Sales_Model_Quote.

Was it helpful?

Solution

Set the store first:

$store = Mage::getSingleton('core/store')->load(1);

$quote = Mage::getModel('sales/quote')->setStore($store)->load($quoteId);

OTHER TIPS

Nope, Mage_Sales_Model_Quote is like all the other db based models. You make something wrong. Maybe hardcode the $quoteId? Are you sure it is correct? Both codes should work.

You could use

$quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);

It works in Magnto Enterprise ver. 1.14.2.4

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top