3

Was working on my database and discovered I had a foreign Key error. No problems, fixed that. However, whilst I was working on the database, a website order came through.

The order shows up in the sales_flat_quote in the database. However, it is not in the following tables:

sales_flat_invoice  
sales_flat_invoice_grid  
sales_flat_order  
sales_flat_order_grid  
sales_flat_quote  
sales_flat_shipment  
sales_flat_shipment_grid 

My question is, how can i take the information from the sales_flat_quote table and apply it to these other tables so that it shows up in the order section of the back end of my website? Can't seem to find any information on the process to achieve this.

I am currently running Magento 1.7.0.2

Thanks in advance hopefully :)

EDIT:

I need to convert the quote to an order. I have found this script (as I have all quote, quote items, quote payment and quote address). The order is valid, as the paypal invoice even has an order number. The foreign key error prevented the invoice from being created.

However, when I run the script, I get this error:

PHP Fatal error:  Uncaught exception 'Mage_Core_Exception' with message 'Cannot retrieve payment method instance.' in /home/user/public_html/app/Mage.php:594

Stack trace:
0 /home/user/public_html/app/code/core/Mage/Payment/Model/Info.php(82): Mage::throwException('The requested P...')

Here is the script:


$quote = Mage::getModel('sales/quote')->load(5428);

$convert = Mage::getModel('sales/convert_quote');

$order = $convert->toOrder($quote);
$order->addressToOrder($quote->getAddress(),$order);

foreach($quote->getAllItems() as $item){
    $orderItem = $convert->itemToOrderItem($item);
    if ($item->getParentItem()) {
       $orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
    }
    $order->addItem($orderItem);
}

$quote->getShippingAddress()->setPaymentMethod('paypal_express');
$quote->getShippingAddress()->setCollectShippingRates(true);

$payment = $quote->getPayment();
$payment->importData($data);
$quote->save();

$payment = $convert->paymentToOrderPayment($quote->getPayment());

$order->setPayment($quote->getPayment());

$message = '[Notice] - Order converted from quote manually';
$order->addStatusToHistory($order->getStatus(), $message);
$order->place();
$order->save();

$quote->setIsActive(false)->save();

Hopefully someone can help......

  • 1
    Something is not clear with your question. You say the order shows up in sales_flat_quote but tlater the same table is listed in the list of tables where the order does not appear. Which is is? – Marius Jul 28 '14 at 6:14
  • Sorry Marius and thank you for taking the time to reply. The sales_flat_quote shouldn't be in the list. That was an error on my behalf. So it should only read: sales_flat_invoice sales_flat_invoice_grid sales_flat_order sales_flat_order_grid sales_flat_shipment sales_flat_shipment_grid thanks Tamara – Tam Jul 28 '14 at 13:01
2

sales_flat_quote does not contain orders.
It contains quotes. that's another fancy way of saying carts.
So not everything that appears in sales_flat_quote should have a correspondence in the orders table. Maybe the customer did not perform a checkout process after all.
Maybe the products are still in cart and the customer abandoned the cart.

There is a chance that you will get an order later, or maybe not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.