首页 文章

如何以编程方式创建可配置产品

提问于
浏览
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)); 为可配置产品设置超级Attributeid = 491吗?为什么这里需要属性的细节?任何人都可以帮我找到以编程方式创建可配置产品的最简单方法 .

1 回答

  • 0

    你必须看到这个链接,这是创建可配置产品的最简单方法,

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

    转到app / design / frontend / default / your thme / template / catalog / product然后打开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
    }
    

相关问题