Дополнительный контроллер для модуля

[16 июля 2019 г.]    Российская сборка Magento 2.52.2
Magento 2: модули и услуги
magereport.com: составление перечня необходимых для установки заплаток SUPEE
#1 Сергей Киев
  • Группа: Пользователь
  • Сообщений: 28
  • Регистрация: 09.02.2011

20.05.2011 12:09

Есть модуль Siller. В админ части есть меню

Designers
  • 1 Manage Items
  • 2 Designers Items (этот раздел я добавил, при клике на него должна загружаться таблица customer_siller в блок )


1. Первое что сделал создал в меню доп раздел Designers Items
    <adminhtml>
		<menu>
			<siller module="siller">
				<title>Designers</title>
				<sort_order>71</sort_order>   
                
               <children>   

                    
                    <items module="siller">
						<title>Manage Items</title>
						<sort_order>0</sort_order>
						<action>siller/adminhtml_siller</action>
					</items>
                    
                <manage translate="title" module="siller">
                    <title>Designers Items</title>
                    <action>siller/adminhtml_designer</action>
                    <sort_order>1</sort_order>
                </manage>
                    
                    
                </children>          
        

			</siller>
		</menu>


2. Добовлил контроллер app/code/local/Silen/Siller/controllers/Adminhtml

DesignerController.php

class Silen_Siller_Adminhtml_DesignerController extends Mage_Adminhtml_Controller_action
{
	protected function _initAction() {
		$this->loadLayout()
			->_setActiveMenu('siller/items')
			->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
		
		return $this;
	}   
 
	public function indexAction() {
		$this->_initAction()
			->renderLayout();
	}
}


3. в /var/www/magento_all_test/app/code/local/Silen/Siller/Block/Adminhtml создал Designer.php

class Silen_Siller_Block_Adminhtml_Designer extends Mage_Adminhtml_Block_Widget_Grid_Container
{
   public function __construct()
  {
    $this->_controller = 'adminhtml_designer';
    $this->_blockGroup = 'siller';
    $this->_headerText = Mage::helper('news')->__('Item Manager');
    $this->_addButtonLabel = Mage::helper('news')->__('Add Item');
    parent::__construct();
  }
}



4 Создал app/code/local/Silen/Siller/Block/Adminhtml/Designer Grid.php

<?php

class Silen_Siller_Block_Adminhtml_Disigner_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
  

  public function __construct()
  {
      parent::__construct();
      $this->setId('idGrid');
      $this->setDefaultSort('id');
      $this->setDefaultDir('ASC');
      $this->setSaveParametersInSession(true);
  }

  protected function _prepareCollection()
  {
      $collection = Mage::getModel('siller/siller')->getCollection();
      $this->setCollection($collection);
      return parent::_prepareCollection();
  }

  protected function _prepareColumns()
  {
      $this->addColumn('id', array(
          'header'    => Mage::helper('news')->__('ID'),
          'align'     =>'right',
          'width'     => '50px',
          'index'     => 'id',
      ));

      $this->addColumn('ScreenName', array(
          'header'    => Mage::helper('news')->__('Title'),
          'align'     =>'left',
          'index'     => 'ScreenName',
      ));

	
		
		$this->addExportType('*/*/exportCsv', Mage::helper('news')->__('CSV'));
		$this->addExportType('*/*/exportXml', Mage::helper('news')->__('XML'));
	  
      return parent::_prepareColumns();
  }

   

}


что я сделал неверно или не доделал?

#2 Дмитрий Федюк
  • Администратор
  • Иконка
  • Группа: Администратор
  • Сообщений: 8995
  • Регистрация: 20.02.2010

20.05.2011 14:14

Что конкретно у вас не работает?

#3 Сергей Киев
  • Группа: Пользователь
  • Сообщений: 28
  • Регистрация: 09.02.2011

23.05.2011 12:28

 Дмитрий Федюк (20.05.2011 14:14) писал:

Что конкретно у вас не работает?


Спасибо уже разобрался

Поделиться темой: