1

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

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

我宁愿不使用 SQL 来执行此操作,也不想手动执行此操作,如果我能提供帮助的话!

提前致谢

4

2 回答 2

3

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

Mage::getResourceModel('catalog/product_type_configurable')
            ->saveProducts($this->getProduct($product), $productIds);
于 2011-01-11T18:03:51.843 回答
1

我一直认为使用SOAP-API是不可能的(如这里所解释的)。

但很快谷歌搜索表明有人显然设法使用 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...
        )
    )
);
于 2011-01-11T16:58:18.170 回答