Magento V1.7 Grid View - Add manufacturer attribute to view

前端 未结 2 1730
轮回少年
轮回少年 2021-01-26 07:23

On this page I want to add the Manufacturer name directly below the name of the item, but can\'t seem to get this to work. Have tried a number of suggestions, but none seem to

2条回答
  •  耶瑟儿~
    2021-01-26 07:50

    Try this, assuming that you are using attribute set to create a 'manufacturer' field in Admin -> Catalog -> Manage Attributes.

    Write a custom module that extend Catalog Product Block Grid /app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php

    Create Block File: app/code/local/MageIgniter/ManufacturerGrid/Block/AdminhtmlCatalog/Product/Grid.php

    class MageIgniter_ManufacturerGrid_Block_Adminhtml_Catalog_Product_Grid extends Mage_Adminhtml_Block_Catalog_Product_Grid
     {
    

    Copy method _prepareCollection() to you custom block and update (line 58)

     $collection = Mage::getModel('catalog/product')->getCollection()
            ->addAttributeToSelect('sku')
            ->addAttributeToSelect('name')
            ->addAttributeToSelect('manufacturer')   // added this line
            ->addAttributeToSelect('attribute_set_id')
            ->addAttributeToSelect('type_id');
    

    Copy method _prepareColumns() to you custom block and add

        $this->addColumn('manufacturer',
            array(
                'header'=> Mage::helper('catalog')->__('Manufacturer'),
                'width' => '60px',
                'index' => 'manufacturer',
                'type'  => 'options';
                'options' => Mage::helper('manufacturergrid')->getManufacturerOption(),
        ));
    

    Create Helper File: app/code/local/MageIgniter/ManufacturerGrid/Helper/Data.php

     class MageIgniter_ManufacturerGrid_Helper_Data extends Mage_Core_Helper_Abstract
     {
    
        public function getManufacturerOption(){
           $_opt = array();
           foreach (Mage::getModel('eav/config')->getAttribute('catalog_product','manufacturer')->getSource()->getAllOptions(false,true) as $option){
               $_opt[$option['value']] = $option['label'];
           }
    
        return $_opt;
       }  
    
     }
    

    Create: app/code/local/MageIgniter/ManufacturerGrid/etc/config.xml

    
      
        
            1.0.0
            
      
    
      
          
            
                
                MageIgniter_ManufacturerGrid_Block_Adminhtml_Catalog_Product_Grid
                
            
          
        
            
                MageIgniter_ManufacturerGrid_Helper
            
        
      
     
    

    Create: app/etc/modules/MageIgniter_ManufacturerGrid.xml

      
        
               
                      
                              true
                              local
                      
               
        
    

提交回复
热议问题