magento -- 修改代碼讓後台屬性組合裏的屬性顯示中文
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值
修改後效果如下
最後更新:2017-04-02 06:51:37