通过可配置产品magento的选项获得简单的产品 [英] get simple product with his options from configurable product magento

查看:112
本文介绍了通过可配置产品magento的选项获得简单的产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我知道简单产品ID以及父产品ID,如何获得简单产品(可配置Parent的子级)选项(例如:color = red)? 我是Magento的新手,我真的需要一些建议.

How can I get a simple products (child of configurable Parent) options (like: color = red) if I know the simple products ID and also the parent Products ID? I am new to Magento and I really need some advice.

推荐答案

// load configurable product
$product = Mage::getModel('catalog/product')->load($productId);

// get simple produts' ids
$childIds = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($product->getId());

// get simple products
$childProducts = Mage::getModel('catalog/product_type_configurable')
                        ->getUsedProducts(null,$product);

// get configurable options
$productAttributeOptions = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
$attributeOptions = array();
foreach ($productAttributeOptions as $productAttribute) {
    foreach ($productAttribute['values'] as $attribute) {
        $attributeOptions[$productAttribute['label']][$attribute['value_index']] = $attribute['store_label'];
    }
}

这篇关于通过可配置产品magento的选项获得简单的产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆