{"id":1032,"date":"2015-07-28T19:52:41","date_gmt":"2015-07-28T19:52:41","guid":{"rendered":"http:\/\/invisiblezero.net\/?p=1032"},"modified":"2024-07-22T09:31:18","modified_gmt":"2024-07-22T09:31:18","slug":"magento-simple-code-snippet-to-remove-redundant-attribute-from-cli","status":"publish","type":"post","link":"http:\/\/ndthanh.com\/magento-simple-code-snippet-to-remove-redundant-attribute-from-cli\/","title":{"rendered":"Magento – Simple code snippet to remove redundant attribute from CLI"},"content":{"rendered":"

if you want to do something like this :<\/p>\n

\nphp -f remove_redundant_attribute.php\n<\/pre>\n

in order to remove redundant attributes, then this article is for you \ud83d\ude42 . yes, i know that Magento setup script is a headache sometime.<\/p>\n

<\/p>\n

to do it, you just need to use the code snippet below for your ‘remove_redundant_attribute.php’ file<\/p>\n

\n&amp;lt;?php\n$mageFilename = getcwd() . &#039;\/app\/Mage.php&#039;;\n\nif (!file_exists($mageFilename)) {\n    echo &#039;Mage file not found&#039;;\n    exit;\n}\nrequire $mageFilename;\nMage::setIsDeveloperMode(true);\numask(0);\nMage::app();\nMage::app()-&amp;gt;setCurrentStore(Mage::getModel(&#039;core\/store&#039;)-&amp;gt;load(Mage_Core_Model_App::ADMIN_STORE_ID));\n\n$installer = Mage::getResourceModel(&#039;catalog\/setup&#039;, &#039;core_setup&#039;);\n\/\/ remove the redundant attributes here\ntry {\n    $installer-&amp;gt;removeAttribute(&#039;catalog_product&#039;,&#039;seo_category&#039;);\n}\ncatch (Exception $e) {\n    echo $e-&amp;gt;getMessage(); die;\n}\n<\/pre>\n

to remove more attributes, please add more ‘$installer->removeAttribute(‘catalog_product’,’seo_category’);’<\/p>\n

i hope you will find this article useful for you.<\/p>\n","protected":false},"excerpt":{"rendered":"

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 \ud83d\ude42 . 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 &amp;lt;?php $mageFilename…<\/p>\n

Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":1480,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[44,60],"tags":[],"aioseo_notices":[],"views":15,"_links":{"self":[{"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/posts\/1032"}],"collection":[{"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/comments?post=1032"}],"version-history":[{"count":3,"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/posts\/1032\/revisions"}],"predecessor-version":[{"id":1481,"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/posts\/1032\/revisions\/1481"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/media\/1480"}],"wp:attachment":[{"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/media?parent=1032"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/categories?post=1032"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/tags?post=1032"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}