Magento的只读和隐藏属性的产品
我想有没有从管理界面编辑一些Magento的产品属性和一些不可见的所有该接口(如存储不应该由人来查看有关产品的一些持久信息的方法用户..它这样做,我能想到的唯一的办法,其他任何建议,欢迎)。
I would like to have some Magento product attributes that are not editable from the admin interface and some that are not visible at all in that interface (as a method of storing some persistent information about a product that should not be viewed by human users.. it's the only way of doing this that i can think of, any other suggestions are welcome).
所以我的问题是:是否所有的Magento属性都必须从管理界面上显示和编辑?如果没有,他们怎么能做出只读或隐藏?
So my question is: Do all Magento attributes have to be visible and editable from the admin interface? If not, how can they be made read-only or hidden?
我注意到,在管理界面有一些只读字段,因此它必须能够做到这一点拉上。这个计算器搜索后,我发现涉及JavaScript的一个可能的解决方案,但我想不走这条路,如果它是在所有可能的。
I noticed that in the admin interface there are some read-only fields, so it must be possible to do this one way or another. After searching stackoverflow for this I found a possible solution involving JavaScript, but I would like to not go down that path if it's at all possible.
确定,它看起来像它可毕竟完成。增加对 catalog_product_load_after
事件的观察后,在 lockAttribute
方法 Mage_Catalog_Model_Abstract
类可以被用来制造一个产品属性只读。这里是code的观测方法:
OK, it looks like it can be done after all. After adding an observer for the catalog_product_load_after
event, the lockAttribute
method of the Mage_Catalog_Model_Abstract
class may be used to make a product attribute read-only. Here is the code for the observer method:
public function lockAttributes($observer) {
$event = $observer->getEvent();
$product = $event->getProduct();
$product->lockAttribute('attribute_code');
}