显示购物车中可配置产品的所选SKU


Showing the chosen SKU of a Configurable Product in the cart

以下问题:您得到了一个具有一个随机属性的可配置产品。例如,客户选择一个尺寸为"XXL"的商品,并将其放入购物车中。在购物车中,我显示的SKU有:

$_item = $this->getItem();
$item_ID = $_item->getProduct()->getId();
$_product = Mage::getModel('catalog/product')->load($item_ID);
echo $_product->getSku();

现在它显示可配置产品的SKU。但我想展示所选产品的SKU(尺寸为XXL e.x.的Simple Prodcut(。这怎么可能?我print_r收集了所有这些项目数据、产品数据等,但唯一可以获取的是相关产品的集合。

您可以使用:

    // check whether there are childrens for this product
    $_product->getHasChildren(); 
    // get the simple products behind the configurable product
    $_product->getChildren(); 

祝你好运!