[转]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。

From: https://blog.csdn.net/iteye_7879/article/details/82123708

 

posted @ 2021-05-06 10:01  ec04  阅读(84)  评论(0编辑  收藏  举报