Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento - Programmatically reorder

Tags:

php

magento

I am currently making a module that requires me to take an order object and make it reorder itself.. thus, creating a new order in the backend with the exact same items and credentials.

This is the code that i have thus far… it doesn’t seem to reorder the item or create and add another backend order.

$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 greatly appreciated!!

like image 302
Dave C Avatar asked Aug 18 '10 15:08

Dave C


1 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();
like image 156
Valentinych Avatar answered Sep 20 '22 16:09

Valentinych