2013-05-06 95 views
0

我想通過xml在magento中導入可配置產品。我導入了簡單的產品。爲了創建可配置的產品,我遵循了這裏給出的過程http://www.magentocommerce.com/boards/viewthread/46844/。 它的工作原理。如果我刪除如何以編程方式創建可配置產品

$data=array('5791'=>array('0'=>array('attribute_id'=>'491','label'=>'vhs','value_index'=>'5','is_percent'=>0,'pricing_value'=>'')),'5792'=>array('0'=>   array('attribute_id'=>'491','label'=>'dvd','value_index'=>'6','is_percent'=>0,'pricing_value'=>''))); 
$product->setConfigurableProductsData($data); 

仍然有效。對我有好處。但我的問題是這樣的代碼:

$data = array('0'=>array('id'=>NULL,'label'=>'Media Format','position'=> NULL,'values'=>array('0'=>array('value_index'=>852,'label'=>'vhs','is_percent'=>0, 
    'pricing_value'=>'0','attribute_id'=>'182'),'1'=>array('value_index'=>853,'label'=>'dvd', 
    'is_percent'=>0,'pricing_value'=>'0','attribute_id'=>'182') 
),'attribute_id'=>182,'attribute_code'=>'media_format','frontend_label'=>'Media Format', 
    'html_id'=>'config_super_product__attribute_0')); 

我不能只使用$product->getTypeInstance()->setUsedProductAttributeIds(array(491)); 設置超屬性Id = 491配置的產品?爲什麼在這裏需要屬性的細節? 任何人都可以幫助我找到以編程方式創建可配置產品的最簡單方法。

回答

0

你必須看到這個鏈接是創建配置的產品的最簡單的方法,

http://blog.omnisubsole.com/2009/07/01/configurable-products-in-magento/

轉到應用程序/設計/前端/缺省的/你的論略/模板/目錄/產品然後打開list.phtml

$product=Mage::getModel('catalog/product')->load($product_id); 
$productType=$product->getTypeID(); 
//Simple Product 
if($productType == 'simple') 
{ 
//get simple product code here 
}       
//Configurable Product 
if($productType == 'configurable') 
{ 
//get Configurable Product code here 
} 
+0

瀏覽此鏈接。該過程與此處http://www.magentocommerce.com/boards/viewthread/46844/中給出的相同。 – smita 2013-05-08 04:40:50

+0

導入的可配置產品。產品從管理面板可見,但在前端看不到。一旦我從管理面板編輯並保存可配置產品,它就會出現在前端。請建議... – smita 2013-05-10 11:00:59

+0

在您想要顯示可配置產品查看頁面或產品列表頁面的頁面的前端? – 2013-05-10 17:26:54

相關問題