2011-02-26 163 views
1

我想将管理中显示的行的默认数量设置为高于20.
我沿着http://inchoo.net/ecommerce/magento/magento-admin-grid-how-to-change-number-of-rows/,但我试图制作一个模块做任务。 Magento版本是1.4.2.0。magento更改在adminhtml网格页面中显示的默认数行

我得到的错误是Mage registry key "_singleton/grid/observer" already exists

我在app/code/local/Company/Custom/etc/config.xml

<config> 
    <adminhtml> 
    <events> 
     <core_block_abstract_prepare_layout_before> 
     <observers> 
      <grid_observer> 
      <class>grid/observer</class> 
      <method>applyLimitToGrid</method> 
      </grid_observer> 
     </observers> 
     </core_block_abstract_prepare_layout_before> 
    </events> 
    </adminhtml> 
</config> 

app/code/local/Company/Custom/Model/Observer.php

class Company_Custom_Grid_Model_Observer 
{ 
    public function applyLimitToGrid(Varien_Event_Observer $observer) 
    { 
     $block = $observer->getEvent()->getBlock(); 
     if (($block instanceof Mage_Adminhtml_Block_Widget_Grid) && !($block instanceof Mage_Adminhtml_Block_Dashboard_Grid)) { 
      $block->setDefaultLimit(200); 
     } 
    } 
} 

app/etc/modules/Company_Custom.xml

<config> 
    <modules> 
    <Company_Custom> 
     <codePool>local</codePool> 
     <active>true</active> 
    </Company_Custom> 
    </modules> 
</config> 

回答

1

类Company_Custom_Grid_Model_Observer

应该

类Company_Custom_Model_Observer

+0

这使我在正确的道路上;班级名称在两个地方实际上是错误的... – elcash 2011-06-07 05:12:30

0

你不必模块模型类声明:

<global> 
    <models> 
    <modulename> 
     <class>Namespace_ModuleName_Model</class> 
    </modulename> 
    </models> 
</global> 
0

最大的变化是在Company/Custom/etc/config.xml,这里我把内的<events>部分0块而不是<adminhtml>

而且该文件中,并修复错误信息是<class>Company_Custom_Model_Observer</class>(其中我收到了grid/observer ...)