2013-12-14 171 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查詢的新方式?我有一個和你一樣的案例。 –