2

I installed a module that added some product attributes but did not remove them on uninstall. Their existence is throwing errors. I expected a "delete attribute" button to be there when I click into the attribute, but the button is missing. What is the SQL to delete product attributes? THANKS

4

The way which I generally follow for these type of tasks is :
First create a test.php in magento root directory
Place below code there

    <?php

    error_reporting(E_ALL | E_STRICT);

    require_once './app/Mage.php';
    umask(0);
    Mage::app();

    $attr = 'test_remove'; //attribute code to remove

    $setup = Mage::getResourceModel('catalog/setup', 'core_setup');
    try {
        $setup->startSetup();
        $setup->removeAttribute('catalog_product', $attr);
        $setup->endSetup();
        echo $attr . " attribute is removed";
    } catch (Mage_Core_Exception $e) {
        print_r($e->getMessage());
    }
3

In a bootstrapped Magento environment, you can just do

$setup = Mage::getResourceModel('catalog/setup','catalog_setup');
$setup->startSetup();
$setup->removeAttribute('catalog_product','attribute_code');
$setup->endSetup();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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