Magento – How to fix deleted manufacturer attribute

attributesdatabaseeav

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,

Best Answer

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