Magento - software reorder

I am currently creating a module that requires me to take an order object and force it to reorder itself .. thus creating a new order in the backend with exactly the same elements and credentials.

This is the code that I still have ... it does not seem to order the element or create or add another backend code.

$personsOrder = Mage::getModel('sales/order'); $personsOrder->loadByIncrementId($order['model_order_id']); $order_model = Mage::getSingleton('adminhtml/sales_order_create'); $personsOrder->setReordered(true); $order_model->initFromOrder($personsOrder); /* $order_model->save(); $order_model->place(); $order_model->sendNewOrderEmail(); */ 

Any help is much appreciated!

+7
php magento
source share
3 answers
 $orderId= $YOUR_ORDER_NUMBER; $personsOrder = Mage::getModel('sales/order')->load($orderId); $order_model = Mage::getSingleton('adminhtml/sales_order_create'); $personsOrder->setReordered(true); $order_model->initFromOrder($personsOrder); $order_model->createOrder(); 
+7
source share

My first thought is that you should use $order->getIncrementId() on line 2, not $order['model_order_id'] , but I'm not sure where you get $order . Have you verified that $order['model_order_id'] really returns a valid increment identifier? I do not see model_order_id as a field in the database anywhere ...

I would suggest that you work with the IDE and XDebug so that you can check objects while working with them and understand what is happening.

Cheers, JD

+3
source share

If the order that you placed for the first time is also created using coding, and not from the store, then you need to make sure that you add an entry to the sales_flat_quote_item table. Otherwise, this order cannot be reordered. Therefore, make sure that this is not the case with the creation of your order.

+1
source share

All Articles