Bulk import grouped products magento

This tutorial explains how to bulk import grouped products magento.The products data are importing from the CSV.

Import grouped products magento

Read CSV

Click here to find out how to read from CSV.

Import main product

Import the main product as same as simple product just change the product typeid.

Please also refer other magento tutorials.

function setGroupedProducts( $product, $simpleProdSkus ) {
    
    try {
       
        $grpProducts = array();
        $simpleProductSkus = explode(',',$simpleProdSkus);
        $i = 0;
        
        foreach ($simpleProductSkus as $simpleProdSku) {
            
            $simple_product = Mage::getModel('catalog/product')->loadByAttribute('sku', $simpleProdSku);
            
            if (is_object($simple_product)) {
                
                $grpProducts[$i++] = $simple_product->getId();
                
            }
        }
         
        $products_links = Mage::getModel('catalog/product_link_api');
        
        foreach($grpProducts as $id) {
            $products_links->assign ("grouped",$product->getId(),$id);
        }
       
        return $product;
    } 
    catch (Exception $ex) {
        Mage::log($ex->getMessage(),null,'grp.log');
    }
    
}

Share this Tutorial