简体   繁体   English

Magento-更新sales_flat_order_item表中发票的数量

[英]Magento - update the qty invoiced in sales_flat_order_item table

I need to change the value of the qty_invoiced column for certain order in the sales_flat_order_item table, but unfortunately nothing happens. 我需要更改sales_flat_order_item表中某些订单的qty_invoiced列的值,但不幸的是没有任何反应。

here is my code: 这是我的代码:

$allOrders = Mage::getModel('sales/order')->getCollection()
    ->addFieldToFilter('status', 'complete');

foreach ($allOrders as $value) {
  $order = Mage::getModel('sales/order')->load($value->getId());
  if($order->getincrementId() == '100000003'){
    foreach ($order->getAllItems() as $item) {
      $qtyOrdered = $item->getQtyOrdered();
      $item->setQtyInvoiced($qtyOrdered);
    }
  }
}

I think you need to save the item and the order after setting the new quantity. 我认为您需要在设置新数量后保存物料和订单。

foreach ($allOrders as $value) {
    $order = Mage::getModel('sales/order')->load($value->getId());
    if($order->getincrementId() == '100000003'){
        /** @var $item Mage_Sales_Model_Order_Item */
        foreach ($order->getAllItems() as $item) {
            $qtyOrdered = $item->getQtyOrdered();
            $item->setQtyInvoiced($qtyOrdered);
            $item->save();

        }
    }
    $order->save();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从magento中的自定义模块在sales_flat_order_item表中添加新字段 - Adding new field in sales_flat_order_item table from custom module in magento Magento - 向sales_flat_quote_item和sales_flat_order_item添加新列 - Magento - Adding a new column to sales_flat_quote_item and sales_flat_order_item 如何将产品特定的属性列添加到sales_flat_order_item表? - How to add product specific attribute column to sales_flat_order_item table? 带有sales_flat_order_item的product_options的_prepareCollection - _prepareCollection with product_options of sales_flat_order_item 在sales_flat_quote和sales_flat_order_item表中添加额外信息 - Adding extra information in sales_flat_quote and sales_flat_order_item tables 在magento中完成订单后,更新sales_flat_order表的自定义列 - Update a custom column of sales_flat_order table after order complete in magento 未完成Magento订单创建sales_flat_quote_item - Magento Order creation sales_flat_quote_item not being made Magento V1.9 在事件观察器中的 sales_flat_quote_item 更新后超时运行 - Magento V1.9 is running in timeout after sales_flat_quote_item update in event observer 如何在magento中插入sales_flat_order_grid - How to insert into sales_flat_order_grid in magento Magento:如何获取订购商品中特定产品的数量? - Magento : How to get qty of a specific product in an order item?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM