【问题标题】:get simple product with his options from configurable product magento使用可配置产品 magento 的选项获得简单的产品
【发布时间】:2014-09-05 22:31:45
【问题描述】:

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

【问题讨论】:

    标签: magento product options configurable


    【解决方案1】:
    // 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'];
        }
    }
    

    【讨论】:

    • 我只需要一个子产品的具体选项,女巫我有身份证,希望你明白我的意思。
    • 有没有办法只使用 API 来实现?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-18
    • 1970-01-01
    • 2012-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多