gpt4 book ai didi

php - Magento 如何以编程方式发送订单?

转载 作者:可可西里 更新时间:2023-11-01 12:53:36 26 4
gpt4 key购买 nike

我正在查看一些代码以在 Magento 中添加 MassAction 并运送并完成来自 sales_order/index 的多个订单

订单未发货。

看起来(一个完全正常的订单)没有通过 canship() 测试。是否应该传递 $orderid$order

这是我的代码

//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);

最佳答案

你需要按ID加载,如果你得到orderID,或者按IncrementOrderId加载,如果你实际得到Order incrementId。

使用这个:

$order = Mage::getModel('sales/order')->load($orderId);

让我们知道它是否有效。

然后:

$shipmentId = $shipment->create($order->getIncrementId(), $itemQty, 'Shipment created through ShipMailInvoice', true, true);

试试吧。

关于php - Magento 如何以编程方式发送订单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9055923/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com