Magento – Simple code snippet to remove redundant attribute from CLI

if you want to do something like this :

php -f remove_redundant_attribute.php

in order to remove redundant attributes, then this article is for you 🙂 . yes, i know that Magento setup script is a headache sometime.

to do it, you just need to use the code snippet below for your ‘remove_redundant_attribute.php’ file

$mageFilename = getcwd() . '/app/Mage.php';

if (!file_exists($mageFilename)) {
    echo 'Mage file not found';
require $mageFilename;

$installer = Mage::getResourceModel('catalog/setup', 'core_setup');
// remove the redundant attributes here
try {
catch (Exception $e) {
    echo $e->getMessage(); die;

to remove more attributes, please add more ‘$installer->removeAttribute(‘catalog_product’,’seo_category’);’

i hope you will find this article useful for you.

Leave a Comment