我想在目录/产品中添加新列注释?我怎么能用这段代码呢?
/* @var $installer Mage_Catalog_Model_Resource_Setup */
$installer = Mage::getResourceModel('catalog/setup','catalog_setup');
$installer->startSetup();
$installer->getConnection()->addColumn(
$installer->getTable('catalog/product'),
'my_column_name',
array(
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
'length' => 255,
'comment' => 'My Column Name'
)
);
$installer->addAttribute(
'catalog_product',
'my_column_name',
array(
'label' => 'Initial Label',
'type' => 'static'
)
);
$installer->endSetup();
如何将此代码添加到我的自定义模块以升级目录/产品的安装脚本?
答案 0 :(得分:0)
答案仅在于你的问题, 在自定义模块中,如果已存在sql安装脚本,则创建升级脚本,或者创建sql安装脚本并记下代码
/* @var $installer Mage_Catalog_Model_Resource_Setup */
$installer = Mage::getResourceModel('catalog/setup','catalog_setup');
$installer->startSetup();
$installer->getConnection()->addColumn(
$installer->getTable('catalog/product'),
'my_column_name',
array(
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
'length' => 255,
'comment' => 'My Column Name'
)
);
$installer->addAttribute(
'catalog_product',
'my_column_name',
array(
'label' => 'Initial Label',
'type' => 'static'
)
);
$installer->endSetup();
答案 1 :(得分:0)
其实我弄清楚了。在我的[namespace] _ [module] _model_resource_setup ..
中刚刚添加了产品新属性的数组列表
'catalog_product' => array(
'entity_model' => 'catalog/product',
'attribute_model' => 'catalog/resource_eav_attribute',
'table' => 'catalog/product',
'attributes' => array(
'mycustomproductcode' => array(
'group' => 'AddedProductattrib/Tab',
'lable' => 'mycustomattrib',
'type' => 'varchar',
'input' => 'text',
'default' => '0',
'class' => '',
'backend' => '',
'frontend' => '',
'source' => '',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'visible' => true,
'required' => false,
'user_defined' => false,
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'visible_in_advance_search' => false,
'unique' => false
)
)
),
//add more entity attributes