Magento的只读和隐藏属性的产品 [英] Magento read-only and hidden product attributes

查看:112
本文介绍了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');
}

这篇关于Magento的只读和隐藏属性的产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆