2013-12-14 118 views
0

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

所以,我想的是:

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

但是,这是行不通的。当我点击管理产品时,产品已创建,但我需要选择第一个可配置属性。所以setConfigurableAttributes没有做任何动作,但它也没有调用任何错误。什么是适当的方式呢?

回答

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)"); 
+0

你有没有使用SQL查询的新方式?我有一个和你一样的案例。 –