magento - Modify the code so that the background attribute combinations in the attribute display Chinese

2011-04-13  来源:本站原创  分类:PHP  人气:120 

Magento background property portfolio management in the various properties shows the properties of the code, that is, even to each property with a Chinese label (label), there is still a large display of English, for a non-technical backstage managers, so many of the English when they want to see, so finding ways to change it.

magento - Modify the code so that the background attribute combinations in the attribute display Chinese

Open the \ app \ code \ local \ Mage \ Adminhtml \ Block \ Catalog \ Product \ Attribute \ Set \ Main.php file, find the number to display the code, replace as follows

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 () is the label for the value of the property, rather than the value of the original code

The revised results are as follows

magento - Modify the code so that the background attribute combinations in the attribute display Chinese

相关文章