Magento相关产品选项

时间:2010-12-16 16:58:01

标签: php magento magento-1.4

我已将所有产品导入为configurable,其选项为simple个产品类型,所有简单产品都具有正确的尺寸属性,可配置产品具有正确的attribute_set

将产品选项与其产品相关联的最佳方式是什么?

我宁愿不用SQL做这件事,或者如果我能帮忙的话也不要手动做!

提前致谢

2 个答案:

答案 0 :(得分:3)

据我了解您的问题,您想将简单产品分配给其'可配置父级? 如果是这样,请查看Mage_Catalog_Model_Product_Type_Configurable模型。有方法save()调用资源模型的方法saveProducts($ mainProduct,$ productIds):

Mage::getResourceModel('catalog/product_type_configurable')
            ->saveProducts($this->getProduct($product), $productIds);

答案 1 :(得分:1)

我一直认为使用SOAP-API无法做到这一点(如here所述)。

但很快谷歌搜索显示有人显然managed to do this using the SOAP-API。以下是论坛帖子中的相关代码:

$this->proxy->call($this->session,
    'catalog_product_link.assign',
    array('configurable',
        $newConfigProdId, //This is the product ID of the configurable product
        $createdVariants, //This is an array of product IDs of simple products to associate to the configurable product
        array(ATTR_ID_COLOR, //This is an array of attribute IDs to create as superAttributes for the configurable product.
            ATTR_ID_SIZE //I've defined them as constants...
        )
    )
);