Reputation: 604
I have a module that takes a feed from another site and then imports the orders into magento. The problem is that despite the orders being created properly and appering in Magento they don't show up in the Products Ordered report.
The reason seems to be that this report looks at the sales_flat_quote_item table to produce its results but there is no entry for my sale items. They do however appear correctly in sales_flat _order_item.
Below is a shortened version of the code.
Any suggestions as to why im not getting an entry in flat_quote_item?
Why does the Magento model used by the Ordered Products report use the quote table and not the order table?
$quote = Mage::getModel('sales/quote')->setStoreId((string) $dataArray->StoreviewId);
if (is_object($product)) {
$product->setPrice(((string) $orderitem->Price) / $reverseRate);
$item = Mage::getModel('sales/quote_item');
$item->setQuote($quote)->setProduct($product);
$item->setData('qty', (string) $orderitem->Quantity);
$item->setCustomPrice((string) $orderitem->Price);
$item->setOriginalCustomPrice((string) $orderitem->Price);
$quote->addItem($item);
}
Upvotes: 5
Views: 1515
Reputation: 151
This code doesn't show any calls to $item->save
or $quote->save
, so it could be that you aren't saving the quote
object.
Upvotes: 3
Reputation: 29922
Why does the Magento model used by the Ordered Products report use the quote table and not the order table?
Because you could have an order, which wasn't paid or was canceled and thus the product wasn't delivered. You still have an order in the system, it just wasn't executed. My guess is, that the specific report should only contain successful order, where the products were shipped or at least the quote was sent.
Any suggestions as to why im not getting an entry in flat_quote_item?
You need to generate the quote, which isn't done automatically on saving an order.
See the following forums thread to get hints on how to generate the quote: http://www.magentocommerce.com/boards/viewthread/28426/P30/
Upvotes: 2