Magento list the selected budle item sku from an order item

 foreach ($order_items as $oi) {
	$_product = Mage::getModel('catalog/product')->loadByAttribute('sku', $oi->getSku());
	$_product =  Mage::getModel('catalog/product')->load($_product->getId());

	if ($_product->getTypeId() == 'bundle') {
		$options = $oi->getProductOptions();
		$optionIds = array_keys($options['info_buyRequest']['bundle_option']);								
		$selectionCollection = $_product->getTypeInstance(true)->getSelectionsCollection(
			$_product->getTypeInstance(true)->getOptionsIds($_product), $_product
		);

		$selected_skus = '' ;
		foreach($selectionCollection as $option)
		{
			if( in_array($option->getData('option_id'), $optionIds)) {
				$selected_skus .= $option->getSku() . ',' ;
			}
		}
		echo $selected_skus ;
	}
}

 

你可能感兴趣的:(select)