Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在购物车中显示可配置产品的选定SKU_Php_Magento - Fatal编程技术网

Php 在购物车中显示可配置产品的选定SKU

Php 在购物车中显示可配置产品的选定SKU,php,magento,Php,Magento,以下问题:您有一个带有一个随机属性的可配置产品。例如,客户选择一个“XXL”尺寸,并将其放入购物车。在购物车中,我显示SKU,其中包含: $_item = $this->getItem(); $item_ID = $_item->getProduct()->getId(); $_product = Mage::getModel('catalog/product')->load($item_ID); echo $_product->getSku(); 现在它显示了

以下问题:您有一个带有一个随机属性的可配置产品。例如,客户选择一个“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的简单Prodcut)。这怎么可能?我打印了所有这些项目数据、产品数据等,但唯一可以获取的是相关产品的集合。

您可以通过以下方式执行此操作:

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

祝你好运

但是像这样,我将获得该CProduct的所有子产品,而不是我以前配置的特定子产品。您是否尝试使用
$this->getUsedProductAttributes()
来比较购物车中的产品和简单产品?还有
$this->getUsedProducts()在类中,但我不知道这是否为简单产品或可配置产品提供了一些有用的信息,请自己尝试。祝你好运我将使用getUsedProductAttributes()方法进行尝试。但事实上,我还没有找到这个方法,我认为用这个方法解决问题是可能的。谢谢