magento - How to create configuarable product programatically -


i want import configurable products in magento through xml. have imported simple products.to create configurable product, followed process given here http://www.magentocommerce.com/boards/viewthread/46844/. works. if 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 works. , me. problem 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 use $product->gettypeinstance()->setusedproductattributeids(array(491)); set super-attributeid =491 configurable product ? why detail of attribute required here? can me find easiest way create configurable product programmatically.

you have see link easiest way create configurable product,

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

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

Comments