通过PHP访问Magento中订单的自定义选项

mat*_*att 14 php magento

我正在加载这样的订单:

$order = Mage::getModel('sales/order')->load(2886);
$items = $order->getAllItems();
Run Code Online (Sandbox Code Playgroud)

然后我使用foreach循环:

foreach ($items as $itemId => $item){
    $name[] = $item->getName();
    $unitPrice[]=$item->getPrice();
    $sku[]=$item->getSku();
    $ids[]=$item->getProductId();
    $qty[]=$item->getQtyToInvoice();
}
Run Code Online (Sandbox Code Playgroud)

而且我能够获得我需要的大部分数据.但是,我在获取为订单选择的自定义选项时遇到问题.我可以在var转储中看到数据,但是我没有成功挖掘它.我也尝试了一些我通过谷歌找到的内置函数,但没有运气.

Jür*_*len 14

matt(OP)已经自己回答了这个问题.

引用:


我能够通过使用获得我需要的东西:

$opts = $item->getProductOptions();
Run Code Online (Sandbox Code Playgroud)

在我的foreach循环中.var_dump上显示了如何轻松访问数据.