如果我知道简单产品 ID 和父产品 ID,如何获得简单产品(可配置 Parent
的子项)选项(如: color = red
)?
我是 Magento 的新手,我真的需要一些建议。
最佳答案
// 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 - 从可配置产品 magento 中获得带有他的选项的简单产品,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24763117/