magento -- 修改代码让后台属性组合里的属性显示中文
来源:互联网 发布:java 设置文件夹权限 编辑:程序博客网 时间:2024/06/05 18:58
Magento后台属性组合管理里的各个属性显示的是属性的code,也就是说,即便给每个属性加上了中文的标签(label),这里显示的依然是大片的英文,对一个不懂技术的后台管理者来说,这样多的英文时他们不愿意看到的,所以要想办法变一下。
打开/app/code/local/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php文件,找到几个用来显示的代码,替换成如下所示
- public function getGroupTreeJson()
- {
- $items = array();
- $setId = $this->_getSetId();
- /* @var $groups Mage_Eav_Model_Mysql4_Entity_Attribute_Group_Collection */
- $groups = Mage::getModel('eav/entity_attribute_group')
- ->getResourceCollection()
- ->setAttributeSetFilter($setId)
- ->load();
- $configurable = Mage::getResourceModel('catalog/product_type_configurable_attribute')
- ->getUsedAttributes($setId);
- /* @var $node Mage_Eav_Model_Entity_Attribute_Group */
- foreach ($groups as $node) {
- $item = array();
- //Alex
- $item['text'] = $this->__($node->getAttributeGroupName());
- $item['id'] = $node->getAttributeGroupId();
- $item['cls'] = 'folder';
- $item['allowDrop'] = true;
- $item['allowDrag'] = true;
- $nodeChildren = Mage::getResourceModel('catalog/product_attribute_collection')
- ->setAttributeGroupFilter($node->getId())
- ->addVisibleFilter()
- ->checkConfigurableProducts()
- ->load();
- if ($nodeChildren->getSize() > 0) {
- $item['children'] = array();
- foreach ($nodeChildren->getItems() as $child) {
- /* @var $child Mage_Eav_Model_Entity_Attribute */
- $attr = array(
- //Alex
- 'text' => $this->__($child->getFrontendLabel()),
- 'id' => $child->getAttributeId(),
- 'cls' => (!$child->getIsUserDefined()) ? 'system-leaf' : 'leaf',
- 'allowDrop' => false,
- 'allowDrag' => true,
- 'leaf' => true,
- 'is_user_defined' => $child->getIsUserDefined(),
- 'is_configurable' => (int)in_array($child->getAttributeId(), $configurable),
- 'entity_id' => $child->getEntityAttributeId()
- );
- $item['children'][] = $attr;
- }
- }
- $items[] = $item;
- }
- return Mage::helper('core')->jsonEncode($items);
- }
- public function getAttributeTreeJson()
- {
- $items = array();
- $setId = $this->_getSetId();
- $collection = Mage::getResourceModel('catalog/product_attribute_collection')
- ->setAttributeSetFilter($setId)
- ->load();
- $attributesIds = array('0');
- /* @var $item Mage_Eav_Model_Entity_Attribute */
- foreach ($collection->getItems() as $item) {
- $attributesIds[] = $item->getAttributeId();
- }
- $attributes = Mage::getResourceModel('catalog/product_attribute_collection')
- ->setAttributesExcludeFilter($attributesIds)
- ->addVisibleFilter()
- ->load();
- foreach ($attributes as $child) {
- $attr = array(
- //Alex
- 'text' => $this->__($child->getFrontendLabel()),
- 'id' => $child->getAttributeId(),
- 'cls' => 'leaf',
- 'allowDrop' => false,
- 'allowDrag' => true,
- 'leaf' => true,
- 'is_user_defined' => $child->getIsUserDefined(),
- 'is_configurable' => false,
- 'entity_id' => $child->getEntityId()
- );
- $items[] = $attr;
- }
- if (count($items) == 0) {
- $items[] = array(
- 'text' => Mage::helper('catalog')->__('Empty'),
- 'id' => 'empty',
- 'cls' => 'folder',
- 'allowDrop' => false,
- 'allowDrag' => false,
- );
- }
- return Mage::helper('core')->jsonEncode($items);
- }
$child->getFrontendLabel()即获取该属性的标签值,而不是原来的code值
修改后效果如下
0 0
- magento -- 修改代码让后台属性组合里的属性显示中文
- magento -- 修改代码让后台属性组合里的属性显示中文
- dedecms后台属性修改
- Magento 修改添加产品的默认属性值
- 文件夹的属性里显示安全选项
- 使枚举类型的选项在VS的属性窗里显示为中文
- 如何修改在系统属性里显示的CPU频率和内存容量
- 奸商如何修改电脑属性里显示的CPU型号和内存容量
- 修改SVN中文件的可执行属性
- 修改SVN中文件的可执行属性
- 在magento前端显示自定义属性值
- Magento中目录添加自定义属性代码
- ASP.NET 的后台代码问题:动态向Table里添加按钮,却提示没有Text属性。
- 利用代码修改layout_marginBottom的属性
- 使用代码修改材质的属性
- Android:代码修改layout_marginBottom的属性
- 用JavaScript修改CSS属性的代码
- 代码修改shape的颜色属性
- 摘录笑话(持续更新中...)
- 用Maven插件生成Mybatis代码
- apache James用户信息的数据库存储和密码问题
- 购物心理
- java.lang包中的public final Math类
- magento -- 修改代码让后台属性组合里的属性显示中文
- 顶级pom和子pom版本批量修改
- LEADTOOLS Silverlight Demo演示大全
- List转DataTable(反射)
- POJ 3299
- ORACLE 临时表空间使用率过高的原因及解决方案
- Struts2之类型转换
- AE+C# GP批量裁剪
- Android 图片OutOfMemory异常bitmap size exceeds VM budget的原因及解决方法