magento添加添加自定义属性

首先要确认所加的attribute属于哪个attribute_group。

1.主要操作三个表:eav_attribute,eav_entity_attribute,catalog_eav_attribute(1.4以上才有的)


2.执行语句:

INSERT INTO `eav_attribute` (`entity_type_id`, `attribute_code`, `attribute_model`, `backend_model`, `backend_type`,
`backend_table`, `frontend_model`, `frontend_input`, `frontend_label`, `frontend_class`, `source_model`, `is_required`,
`is_user_defined`, `default_value`, `is_unique`, `note`) VALUES
(9, ‘custom_attribute’, NULL, ”, ‘text’, ”, ”, ‘textarea’, ‘Hot Right Now’, NULL, ”, 0, 0, ”, 0, ”);
执行完了之后,记录下返回的id。

3.执行语句:
INSERT INTO `eav_entity_attribute` (`entity_type_id`, `attribute_set_id`, `attribute_group_id`, `attribute_id`,
`sort_order`) VALUES
(9, 12, 7, 第二步中返回的id, 7);

4.执行语句:
INSERT INTO `catalog_eav_attribute` (`attribute_id`, `frontend_input_renderer`, `is_global`, `is_visible`, `is_searchable`,
`is_filterable`, `is_comparable`, `is_visible_on_front`, `is_html_allowed_on_front`, `is_used_for_price_rules`,
`is_filterable_in_search`, `used_in_product_listing`, `used_for_sort_by`, `is_configurable`, `apply_to`,
`is_visible_in_advanced_search`, `position`, `is_wysiwyg_enabled`, `is_used_for_promo_rules`) VALUES
(第二步中返回的id, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, ”, 0, 1, 1, 1);

5.进入后台刷新,就能看到你的attribute。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值