Я знаю, что этот вопрос задавался так много раз здесь, но ничего не помогло мне решить мою проблему.Контейнер сетки пользовательского модуля не отображается
Я пытаюсь отобразить сетку на моей индексной странице модулей, но она не отображается, я пытался сделать var_dump
Mage::getModel('custombundle/bundle')->getCollection()
в цикле и дал мне вывод данных. Ниже то, что я закодированы до сих пор:
config.xml
<?xml version="1.0"?>
<config>
<modules>
<Company_CustomBundle>
<version>1.0.1</version>
</Company_CustomBundle>
</modules>
<admin>
<routers>
<custombundle>
<use>admin</use>
<args>
<module>Company_CustomBundle</module>
<frontName>admin_custombundle</frontName>
</args>
</custombundle>
</routers>
</admin>
<global>
<helpers>
<custombundle>
<class>Company_CustomBundle_Helper</class>
</custombundle>
</helpers>
<!-- Blocks -->
<blocks>
<company_custombundle>
<class>Company_CustomBundle_Block</class>
</company_custombundle>
</blocks>
<models>
<custombundle>
<class>Company_CustomBundle_Model</class>
<resourceModel>custombundle_resource</resourceModel>
</custombundle>
<custombundle_resource>
<class>Company_CustomBundle_Model_Resource</class>
<entities>
<basket>
<table>custombundle_basket</table>
</basket>
<bundle>
<table>custombundle_bundle</table>
</bundle>
</entities>
</custombundle_resource>
</models>
<resources>
<custombundle_setup>
<setup>
<module>Company_CustomBundle</module>
<class>Company_CustomBundle_Model_Resource_Setup</class>
</setup>
</custombundle_setup>
<custombundle_write>
<connection>
<use>core_write</use>
</connection>
</custombundle_write>
<custombundle_read>
<connection>
<use>core_read</use>
</connection>
</custombundle_read>
</resources>
</global>
<adminhtml>
<!-- Layouts Configuration Starts -->
<layout>
<updates>
<custombundle>
<file>custombundle.xml</file>
</custombundle>
</updates>
</layout>
<!-- !! Layouts Configuration -->
<menu>
<custombundle module="custombundle">
<title>Custom Bundle</title>
<sort_order>100</sort_order>
<children>
<index module="custombundle">
<title>Custom Bundle</title>
<sort_order>0</sort_order>
<action>admin_custombundle/adminhtml_custombundle</action>
</index>
<other module="custombundle">
<title>Other</title>
<sort_order>0</sort_order>
<action>admin_custombundle/adminhtml_custombundle/other</action>
</other>
</children>
</custombundle>
</menu>
</adminhtml>
</config>
приложение/дизайн/adminhtml/по умолчанию/по умолчанию/макет/custombundle.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<adminhtml_custombundle_index> <!-- custombundle controller index action -->
<reference name="content">
<block type="company_custombundle/adminhtml_custombundle_bundle" name="list_combination" />
</reference>
</adminhtml_custombundle_index>
</layout>
контроллеры/Adminhtml/CustombundleController.php
public function indexAction()
{
$this->_title($this->__('Custom Bundle'))->_title($this->__('Category Combinations'))->loadLayout()->_setActiveMenu('custombundle/index');
$this->renderLayout();
}
Block/Adminhtml/Custombundle/Bundle.php
class Company_CustomBundle_Block_Adminhtml_Custombundle_Bundle extends Mage_Adminhtml_Block_Widget_Grid_Container
{
public function __construct()
{
$this->_controller = 'adminhtml_custombundle';
$this->_blockGroup = 'company_custombundle';
$this->_headerText = Mage::helper('company_custombundle')->__('Custom Bundle Category combinations');
$this->_addButtonLabel = Mage::helper('company_custombundle')->__('Add Item');
parent::__construct();
}
}
Block/Adminhtml/Custombundle/Bundle/Grid.php
class Company_CustomBundle_Block_Adminhtml_Custombundle_Bundle_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
public function __construct()
{
parent::__construct();
$this->setId('bundleGrid');
$this->setDefaultSort('bundle_id');
$this->setDefaultDir('DESC');
$this->setSaveParametersInSession(true);
}
protected function _prepareCollection()
{
$collection = Mage::getModel('custombundle/bundle')->getCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
$this->addColumn('bundle_id', array(
'header' => 'ID',
'align' => 'right',
'width' => '50px',
'index' => 'bundle_id',
));
$this->addColumn('assigned_category_id', array(
'header' => 'Assigned with',
'align' => 'left',
'index' => 'assigned_category_id',
));
$this->addColumn('category_id', array(
'header' => 'Category',
'align' => 'left',
'index' => 'category_id',
));
return parent::_prepareColumns();
}
public function getRowUrl($row)
{
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
}
}
в «контроллерах/Adminhtml/CustombundleController.php» вы добавили объявление класса? – dharth
да, это есть @dharth Я только что положил 'indexAction' –
ok, в вашем макете попробуйте использовать« custombundle_adminhtml_custombundle_index »вместо« adminhtml_custombundle_index » – dharth