Я смотрю какой-то код, чтобы добавить MassAction
в Magento и отправить и выполнить несколько заказов от sales_order/index
Почему-то заказы не отправляются.
Похоже (совершенно нормальный порядок) не проходит тест canship()
. Должно ли оно быть пройдено $order
из $orderid
?
Вот мой код
//Get orderids
$orderIds = $this->getRequest()->getPost('order_ids');
//verify if the array is not empty
if (!empty($orderIds)) {
//loop through orders
foreach ($orderIds as $orderId) {
// Dont know what this does
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
// Is the order shipable?
if($order->canShip())
{
$itemQty = $order->getItemsCollection()->count();
// This first definition and 2nd look overlapping, our one is obsolete?
$shipment = Mage::getModel('sales/service_order', $order)->prepareShipment($itemQty);
$shipment = new Mage_Sales_Model_Order_Shipment_Api();
// But still, no shipment, why?
$shipmentId = $shipment->create($orderId, array(), 'Shipment created through ShipMailInvoice', true, true);