1

A client was adding manufacturer values to the respective attribute in the backend and accidentally deleted the attribute. Immediately they noticed the site was giving error messages, noticed us and we found the above mentioned action.

We don't have a recent back-up of the database and I want to know if there is a way to manually add the manufacturer attribute back to the database structure and import the values.

Any other suggestions on how to fix this issue are welcomed.

Thanks,

1
  • Did you managed to fix it mate? Commented Apr 12, 2016 at 10:45

2 Answers 2

1

The attribute is created by Mage_Catalog_Model_Resource_Setup, therefore you should be able to recreate it:

$installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'manufacturer', array(
                    'type'                       => 'int',
                    'label'                      => 'Manufacturer',
                    'input'                      => 'select',
                    'required'                   => false,
                    'user_defined'               => true,
                    'searchable'                 => true,
                    'filterable'                 => true,
                    'comparable'                 => true,
                    'visible_in_advanced_search' => true,
                    'apply_to'                   => Mage_Catalog_Model_Product_Type::TYPE_SIMPLE,
                )
);

Throw this code snippet into one of your install scripts and this should do the job

Code is copied from here app/code/core/Mage/Catalog/Model/Resource/Setup.php:491

1

Without a backup I'm afraid you are in trouble.
When an attribute is deleted the links between that attribute and any attribute sets are deleted and the attribute values for all the products are deleted for that specific attribute. Not to mention the attribute options.

Possible solution:
Recreate the attribute with all it's values (manually or through an upgrade script). Here is an example for the upgrade script..

Assign the attribute to the attribute sets.
If your attribute was in all the attribute sets then you can do it from the upgrade script just by adding an other element to the config array:

'group'=>'General', //the value can be anything.

And if you have a way of finding out which product had which value you can use the import/export feature of Magento.
Export all the products after you add the attribute. You should see a blank column with the attribute code as header in the exported file, remove all the columns except this one and the sku column, fill in the values for your attribute and import the file again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.