Magento创建可配置产品但没有子产品数据

时间:2013-12-14 11:50:08

标签: magento

我检查了一些现有问题,但没有一个解释如何创建没有子产品数据的可配置产品。我不需要链接产品,我只需要创建可配置的产品供以后使用。

所以我试过了:

$_prod->setTypeId('configurable');  
$_prod->setConfigurableAttributes('color');

但这不起作用。当我在产品上单击admin时,会创建产品,但我需要选择第一个可配置属性。所以setConfigurableAttributes没有做任何动作,但它也没有调用任何错误。适当的方法是什么?

1 个答案:

答案 0 :(得分:0)

我最终得到了以下原始查询:

$colorAttrId = 92;
$tableName = Mage::getSingleton('core/resource')->getTableName('catalog_product_super_attribute');
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
$write->query("INSERT IGNORE INTO $tableName (`product_id`, `attribute_id`) VALUES ($prodId,$colorAttrId)");