Magento - 获取已订购捆绑项目的子项/选项

Nat*_*att 5 magento

我很难获得所有子产品及其订购捆绑商品的选项。这可能吗?

Ser*_*Guk 5

您可以通过以下方法找出哪些产品应与所有其他项目一起附加到列表中的捆绑产品中:

foreach ($order->getAllItems() as $item) {
     //if a product has parents (simple product of configurable/bundled/grouped product) load his Parent product type
     if ( $item->getParentItemId()) {
         $parent_product_type = Mage::getModel('sales/order_item')->load($item->getParentItemId())->getProductType();
          //if Parent product type is Bundle
          if ($parent_product_type == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
              // your code goes here (do whatever you need to do)
          }
      }
}
Run Code Online (Sandbox Code Playgroud)