require_once 'app/Mage.php';
umask(0);
Mage::app('default');
$configurableProducts = Mage::getResourceModel('catalog/product_collection')
                ->addAttributeToSelect('associated_skus')
                ->addAttributeToFilter('type_id', array('eq' => 'configurable'));
/*loop though configurable products*/
foreach($configurableProducts as $c){
	/*check to see if product hasnt been done*/
	if(empty($c->getAssociatedSkus())){
		$associatedProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$c);
$skus = [];
/* loop through associated products and add skus to array*/
		foreach($associatedProducts as $a){
			$skus[] = $a->getSku();
		}

		/* set product attribute, then save product*/
		$c->setAssociatedSkus(implode(' ',$skus));
		try{
				Mage::log('skus associated sucessfully:)',null,'assoc.log');
				$c->save();
		}catch(Exception $e){
				Mage::log($e->getMessage().'- /assSku.php',null,' assoc.log ');
		}
	}
}	
Your Answer
Sign In
Enter email and password to comment or answer
Not the answer you are looking for? Browse other questions tagged or ask your own question.