Import grouped products magento

This tutorial explains how to 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.

Create main product

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

Import_grouped_products_magento_1

Import grouped products

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

Also refer the tutorial how to import simple and configurable products magento 2.

Share this Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *

*