0
votes

I want to import configurable products in magento through xml. I have imported simple products.To create configurable product, I followed the process given here http://www.magentocommerce.com/boards/viewthread/46844/. It works. If I remove

$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);

Still it works. and its good for me. But my problem is this code:

$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'));

Can't i use just $product->getTypeInstance()->setUsedProductAttributeIds(array(491)); to set super-Attributeid =491 for configurable product ? Why the detail of attribute is required here? Can anybody help me to find easiest way to create configurable product programmatically.

1

1 Answers

0
votes

you have to see this link this is easiest way to create configurable product,

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

goto app/design/frontend/default/your thme/template/catalog/product then open 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
}