我们正在编写Magento和MAS90 ERP系统的同步 . 我们正在将订单从Magento转移到ERP系统 . 我们为order_save_after添加了观察者 .
每个Magento Simple产品都有UPC代码,需要在ERP系统中添加项目 . 简单的产品会根据可配置的项目自动添加到Magento Order,但问题是简单产品的实际价格,数量,税额...存储在可配置产品中,但UPC存储在简单产品中 . 为了解决这个问题,我们决定从Magento Order获得简单的产品(以获得正确的UPC) .
我们的问题是,如何获得自动添加简单产品的正确价格,数量,税额 . (如何在Magento订单中链接可配置产品并自动添加简单产品 . )
希望你能理解我的问题并抱歉英语不好 .
以下是获取产品的代码片段 .
foreach ($order->getAllItems() as $orderItem){
$tmpMAS90OrderItem = NULL;
if($orderItem->getProductType() == 'simple'){
$tmpMAS90OrderItem = $orderItem -> getUpc();
}
if($tmpMAS90OrderItem != NULL) {
$setChildValuesArray = array(
'ItemCode' => $tmpMAS90OrderItem,
'UnitPrice' => $orderItem -> getPrice(), // THIS IS WRONG PRICE, right price is in configurable item
'QuantityOrdered' => $orderItem -> getQtyToInvoice()
);
$querySO->setChildFieldValues($setChildValuesArray,$childSequence); //child sequence ( line sequence )
$childSequence++;
$linesTaxAmountSum += $orderItem->getTaxAmount(); // THIS IS WRONG TAX AMOUNT, right amount is in configurable item
}
}
1 回答
谢谢StackExchange Network . 我得到了答案 .
在这种情况下,你需要使用呼叫父项的行() . 按照当
configurable product
是ordered
Magento的,然后有two rows has been saved
在sales_flat_order_item
. 一是配置产品数据的product_id和订单项目的价格和另一个是Simple products details
. 所以需要数据fetch data from Configurable products
.So need to change
From
Also To:
From:
From: magento.stackexchange.com ->Get Configurable Product Price from Simple Product in Magento Order