开发者

Magento Associated Product Options

I have imported all of my products as configurable and their options as simple product types, all the simple products have the correct size attributes and the configurable products have the right attribute_set.

What is the best way of associating the product options with their products?

I would 开发者_C百科rather not do this with SQL, or manually if I can help it!

Thanks in advance


As I understand your question, you want to assign simple products to its' configurable parent? If so, please look at Mage_Catalog_Model_Product_Type_Configurable model. There is method save() which call resource model's method saveProducts($mainProduct, $productIds):

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


I always thought this wasn't possible using the SOAP-API (as explained e.g. here).

But quickly googling has shown that somebody apparently managed to do this using the SOAP-API. Here's the relevant code from the forum post:

$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...
        )
    )
);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜