2014-09-29 99 views

回答

0

我會假設你問如何在代碼中做到這一點?總之,只要建立與安裝腳本中的一個小模塊(教程所有網站上),並安裝腳本是這個樣子:

$installer = $this; 
$installer->startSetup(); 

// check if the attribute exists 
if (Mage::getModel('catalog/resource_eav_attribute')->loadByCode('catalog_product','calculated_sold')->getId() !== NULL) { 
    $installer->removeAttribute('catalog_product', 'calculated_sold'); 
} 

// not anymore, that's for sure! 
// Note! For product attributes the XML set class needs to be "Mage_Catalog_Model_Resource_Setup" 
// instead of "Mage_Customer_Model_Entity_Setup" as you would usually go with. 
$installer->addAttribute('catalog_product','calculated_sold', array (
    'type'      => 'decimal', 
    'label'      => 'Calculated sold', 
    'input'      => 'price',   // for filtering to work only certain input types allowed 
    'global'      => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, 
    'searchable'     => true, 
    'filterable'     => true, 
    'visible'     => false, 
    'required'     => false, 
    'visible_in_advanced_search' => true, 
    'used_in_product_listing' => true, 
    'used_for_sort_by'   => true, 
    'apply_to'     => 'configurable', // yeah! 
)); 

$installer->endSetup(); 

此示例將一個屬性來跟蹤有多少項目出售,但它會讓你知道如何根據自己的需求來改變它。

相關問題