【发布时间】:2010-12-16 16:58:00
【问题描述】:
我已将我的所有产品导入为configurable,并将它们的选项导入为simple 产品类型,所有简单产品都具有正确的尺寸属性,可配置产品具有正确的attribute_set。
将产品选项与其产品相关联的最佳方式是什么?
如果可以的话,我宁愿不使用 SQL 或手动执行此操作!
提前致谢
【问题讨论】:
标签: php magento magento-1.4
我已将我的所有产品导入为configurable,并将它们的选项导入为simple 产品类型,所有简单产品都具有正确的尺寸属性,可配置产品具有正确的attribute_set。
将产品选项与其产品相关联的最佳方式是什么?
如果可以的话,我宁愿不使用 SQL 或手动执行此操作!
提前致谢
【问题讨论】:
标签: php magento magento-1.4
据我了解您的问题,您想将简单产品分配给其可配置的父级吗? 如果是这样,请查看 Mage_Catalog_Model_Product_Type_Configurable 模型。有方法 save() 调用资源模型的方法 saveProducts($mainProduct, $productIds):
Mage::getResourceModel('catalog/product_type_configurable')
->saveProducts($this->getProduct($product), $productIds);
【讨论】:
$this 正常工作?我想为每个可配置产品创建一个简单的 php 文件,其中包含我的简单产品 ID 数组
我一直认为使用 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...
)
)
);
【讨论】: