如何在销售订单中查找产品父级

时间:2013-12-21 05:21:36

标签: magento

我使用订单号获取以下信息。 如何找到产品父类型产品是捆绑产品。

<?php
require_once('app/Mage.php'); //Path to Magento
umask(0);
Mage::app("default");

$orderNumber = 260038;  

$order = Mage::getModel('sales/order')->loadByIncrementId($orderNumber);

    // get order item collection
$orderItems = $order->getItemsCollection();


    $skuQtyArray = array();
    foreach ($orderItems as $item)
    {   
       $product_id = $item->product_id;
          //**How to find here if above product's parent was a bundle product**

    }       


?>

enter image description here

1 个答案:

答案 0 :(得分:2)

你可以这样检查

<?php
    require_once('app/Mage.php'); //Path to Magento
    umask(0);
    Mage::app("default");

    $orderNumber = 260038;  

    $order = Mage::getModel('sales/order')->loadByIncrementId($orderNumber);

    // get order item collection
    $orderItems = $order->getItemsCollection();


    $skuQtyArray = array();
    foreach ($orderItems as $item)
    {   
        $product_id = $item->product_id;
        $_product=Mage::getModel('catalog/product')->load($product_id);
        if ($_product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {

            echo 'Bundled';//Do your stuf here
        }
        //**How to find here if above product's parent was a bundle product**

    }       


?>