最新消息:觉得本站不错的话 记得收藏哦 博客内某些功能仅供测试 讨论群:135931704 快养不起小站了 各位有闲钱就打赏下把 My Email weicots#gmail.com Please replace # with @

Magento 1x 后台开发笔记

Magento 资料整理 ajiang-tuzi 4979浏览

一般要重定义(推荐使用rewrite机制)两处: 1. ProductController.php 2. Tabs.php 在Tabs.php的_prepareLayout方法中增加一个Tab Link,如:

$this->addTab('related_documents', array(
 'label' => Mage::helper('catalog')->__('Extra Infomation'),
 'url' => $this->getUrl('*/*/extraInfo', array('_current' => true)),
 'class' => 'ajax')
);

在ProductController.php中增加方法extraInfoAction方法. 内容可能如下:

require_once"Mage/Adminhtml/controllers/Catalog/ProductController.php";
class Cartz_MyAdminhtml_Catalog_ProductController extends Mage_Adminhtml_Catalog_ProductController 
{

public function extraInfoAction() {


echo 'Extra Information.';


exit;

}
}
<?xml version="1.0"?>  
<config>  
    <menu>  
        <!-- 父菜单项标识,此处是在标题为Customers的菜单下加入子菜单-->  
        <!-- Magento一级管理菜单标识和显示标题-->  
        <!--  
             dashboard =>Dashboard  
             catalog=>Catalog  
             sales=>Sales  
             customer=>Customers  
             newsletter=>Newsletter  
             cms=>CMS  
             report=>Reports  
        -->  
  
        <customer>  
            <children>  
                <!--子菜单标识符-->  
                <message translate="title" module="customermessage">  
                    <title>Customer Message</title>  
                <!--点击菜单时执行的动作,  
此处将执行controller/adminhtml目录下的messageController默认的action  
               -->  
                    <action>adminhtml/message</action>  
                    <sort_order>120</sort_order>  
                </message>  
            </children>  
         </customer>  
    </menu>  
   <!--加入权限列表-->  
    <acl>  
        <resources>  
            <admin>  
                <children>  
                    <customer>  
                        <children>  
                            <message translate="title" module="customermessage">  
                                <title>Customer Message</title>  
                                <sort_order>120</sort_order>  
                            </message>  
                        </children>  
                    </customer>  
                </children>  
            </admin>  
        </resources>  
    </acl>  
</config>

参考 后台Grid 表

<?php
/**
 * Created by PhpStorm.
 * User:ajiang-tuzhi
 * QQ:1050653098@qq.com
 * WebSite:www.weicot.com
 * Date: 2016/01/04
 * 导出插件扩展 测试
 * Time: 11:54
 */
class Raveinfosys_Exporter_Block_Adminhtml_Exporter_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
   public function __construct()
   {
        parent::__construct();
        $this->setId('sales_order_export_grid');
        $this->setUseAjax(true);
        $this->setDefaultSort('created_at');
        $this->setDefaultDir('DESC');
        $this->setSaveParametersInSession(true);
    }

    /**
     * Retrieve collection class
     *
     * @return string
     */
    protected function _getCollectionClass()
    {
        return 'sales/order_grid_collection';
    }

    protected function _prepareCollection()
    {
        $collection = Mage::getResourceModel($this->_getCollectionClass());
        $this->setCollection($collection);
        return parent::_prepareCollection();
    }

    protected function _prepareColumns()
    {

        $this->addColumn('real_order_id', array(
            'header'=> Mage::helper('sales')->__('Order #'),
            'width' => '80px',
            'type'  => 'text',
            'index' => 'increment_id',
        ));

        if (!Mage::app()->isSingleStoreMode()) {
            $this->addColumn('store_id', array(
                'header'    => Mage::helper('sales')->__('Purchased From (Store)'),
                'index'     => 'store_id',
                'type'      => 'store',
                'store_view'=> true,
                'display_deleted' => true,
            ));
        }

        $this->addColumn('created_at', array(
            'header' => Mage::helper('sales')->__('Purchased On'),
            'index' => 'created_at',
            'type' => 'datetime',
            'width' => '100px',
        ));

        $this->addColumn('billing_name', array(
            'header' => Mage::helper('sales')->__('Bill to Name'),
            'index' => 'billing_name',
        ));

        $this->addColumn('shipping_name', array(
            'header' => Mage::helper('sales')->__('Ship to Name'),
            'index' => 'shipping_name',
        ));

        $this->addColumn('base_grand_total', array(
            'header' => Mage::helper('sales')->__('G.T. (Base)'),
            'index' => 'base_grand_total',
            'type'  => 'currency',
            'currency' => 'base_currency_code',
        ));

        $this->addColumn('grand_total', array(
            'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
            'index' => 'grand_total',
            'type'  => 'currency',
            'currency' => 'order_currency_code',
        ));

        $this->addColumn('status', array(
            'header' => Mage::helper('sales')->__('Status'),
            'index' => 'status',
            'type'  => 'options',
            'width' => '70px',
            'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
        ));

        if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
            $this->addColumn('action',
                array(
                    'header'    => Mage::helper('sales')->__('Action'),
                    'width'     => '50px',
                    'type'      => 'action',
                    'getter'     => 'getId',
                    'actions'   => array(
                        array(
                            'caption' => Mage::helper('sales')->__('View'),
                            'url'     => array('base'=>'adminhtml/sales_order/view'),
                            'field'   => 'order_id'
                        )
                    ),
                    'filter'    => false,
                    'sortable'  => false,
                    'index'     => 'stores',
                    'is_system' => true,
            ));
        }
        

        return parent::_prepareColumns();
    }

    protected function _prepareMassaction()
    {
        $this->setMassactionIdField('entity_id');
        $this->getMassactionBlock()->setFormFieldName('order_ids');
        $this->getMassactionBlock()->setUseSelectAll(false);

        $this->getMassactionBlock()->addItem('export_order', array(
                 'label'=> Mage::helper('sales')->__('Export Orders'),
                 'url'  => $this->getUrl('*/*/exportCsv'),
        ));
        $this->getMassactionBlock()->addItem('export_order_customer', array(
            'label'=> Mage::helper('sales')->__('Export Customer'),
            'url'  => $this->getUrl('*/*/exportCustomerCsv'),
        ));
			
		
        return $this;
    }
	
	 public function getGridUrl()
	 {
	   return $this->getUrl('*/*/grid', array('_current'=>true));
	 }
	 
	 public function getRowUrl($row)
     {
      return false;
     }

    

}

备注 及引用
本笔记 部分来自互联网 仅供学习和交流所用

转载请注明:(●--●) Hello.My Weicot » Magento 1x 后台开发笔记

蜀ICP备15020253号-1