startSetup(); // make attribute 'weight' not applicable to downloadable products $applyTo = explode(',', $installer->getAttribute('catalog_product', 'weight', 'apply_to')); if (in_array('downloadable', $applyTo)) { $newApplyTo = array(); foreach ($applyTo as $key=>$value) { if ($value != 'downloadable') { $newApplyTo[] = $value; } } $installer->updateAttribute('catalog_product', 'weight', 'apply_to', join(',', $newApplyTo)); } else { $installer->updateAttribute('catalog_product', 'weight', 'apply_to', join(',', $applyTo)); } // remove 'weight' values for downloadable products if there were any created $attributeId = $installer->getAttributeId('catalog_product', 'weight'); $installer->run(" DELETE FROM {$installer->getTable('catalog_product_entity_decimal')} WHERE (entity_id in ( SELECT entity_id FROM {$installer->getTable('catalog/product')} WHERE type_id = 'downloadable' )) and attribute_id = {$attributeId} "); $installer->endSetup();