2014-05-21 90 views
2

我試圖在Magento刪除自定義屬性從銷售/報價屬性,下面的代碼添加我只需要相當於使用Magento的安裝腳本刪除屬性:刪除自定義在Magento

<?php 
$installer = $this; 
$installer->startSetup(); 

$installer->addAttribute("customer", "is_school", array(
    "type"  => "int", 
    "backend" => "", 
    "label" => "is_school?", 
    "input" => "int", 
    "source" => "", 
    "visible" => false, 
    "required" => false, 
    "default" => "", 
    "frontend" => "", 
    "unique"  => false, 
    "note"  => "" 
)); 

$installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'is_school', 'int(11)'); 
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'is_school', 'int(11)'); 

// need code to remove these two column above 

$installer->endSetup(); 
+0

[通過安裝程序腳本刪除Magento中的自定義屬性](http://stackoverflow.com/questions/23775867/removing-a-custom-attribute-in-magento-via-an-installer-script ) – Slimshadddyyy

回答

1

的Magento class ::的方法是Mage_Eav_Model_Entity_Setup::removeAttribute()

所以,您的安裝/升級程序將包含類似以下內容:

$installer->removeAttribute("customer", "is_school"); 

希望有所幫助。