I'm configuring a magento webshop for one of our clients. They've got colorcodes and due to that I have to set up configurable products. However, before the configurable products are being shown on the webshop I need to select an attribute to assign to it...
Now this is really unhandy if I have to import an entire catalog of +/- 800 products...
I already found the next script to make this automatically but I have no clue where to put it... I've already tried using it in the configurable.php file, didn't work. Please help me out!
foreach($configAttrCodes as $attrCode){
$super_attribute= Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product',$attrCode->code);
$configurableAtt = Mage::getModel('catalog/product_type_configurable_attribute')->setProductAttribute($super_attribute);
$newAttributes[] = array(
'id' => $configurableAtt->getId(),
'label' => $configurableAtt->getLabel(),
'position' => $super_attribute->getPosition(),
'values' => $configurableAtt->getPrices() ? $configProduct->getPrices() : array(),
'attribute_id' => $super_attribute->getId(),
'attribute_code' => $super_attribute->getAttributeCode(),
'frontend_label' => $super_attribute->getFrontend()->getLabel(),
);
echo "test ";
}
echo "test2 ";
if(empty($existingAtt) && !empty($newAttributes)){
$configProduct->setCanSaveConfigurableAttributes(true);
$configProduct->setConfigurableAttributesData($newAttributes);
$configProduct->save();