Magento的窗口小部件电网只触发构建(Magento Widget Grid only fire

2019-10-21 18:40发布

我的工作与网格管理员Magento的模块上和我遇到一个奇怪的问题。

该块被装载,所以是延伸Mage_Adminhtml_Block_Widget_Grid类,但网格widget类仅焙烧构建体而不是_prepareCollection()或_prepareColumns()方法。

如果我手动触发_prepareCollection()方法,我得到我的收藏,所以我知道的工作。 我可以证实,所有的布局文件的正确加载。

与没有在PHP,Apache或Magento的错误日志我在哪里寻找这个问题有点难倒了:(

有没有人碰到类似的情况? 如果是的话是什么原因? 有没有人有Magento的调试任何建议,当有任何日志中没有错误?

XML配置是:

<?xml version="1.0"?>

<modules>
    <Fisheye_Enquiryforms>
        <version>0.1.0</version>
    </Fisheye_Enquiryforms>
</modules>

<frontend>

    <routers>
        <fisheye_enquiryforms>
            <use>standard</use>
            <args>
                <module>Fisheye_Enquiryforms</module>
                <frontName>enquiryforms</frontName>
            </args>
        </fisheye_enquiryforms>
    </routers>

    <layout>
        <updates>
            <fisheye_enquiryforms>
                <file>fisheye/enquiryforms/enquiryforms.xml</file>
            </fisheye_enquiryforms>  
        </updates>
    </layout>

</frontend>

<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <Fisheye_Enquiryforms before="Mage_Adminhtml">Fisheye_Enquiryforms_Adminhtml</Fisheye_Enquiryforms>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>

<adminhtml>
    <layout>
        <updates>
            <fisheye_enquiryforms>
                <file>fisheye/enquiryforms/enquiryforms.xml</file>
            </fisheye_enquiryforms>
        </updates>
    </layout>
</adminhtml>

<global>

    <blocks>
        <fisheye_enquiryforms>
            <class>Fisheye_Enquiryforms_Block</class>
        </fisheye_enquiryforms>
    </blocks>

    <helpers>
        <fisheye_enquiryforms>
            <class>Fisheye_Enquiryforms_Helper</class> 
        </fisheye_enquiryforms>
    </helpers>

    <models>
        <fisheye_enquiryforms>
            <class>Fisheye_Enquiryforms_Model</class>
            <resourceModel>fisheye_enquiryforms_mysql4</resourceModel>
        </fisheye_enquiryforms>
        <fisheye_enquiryforms_mysql4>
            <class>Fisheye_Enquiryforms_Model_Mysql4</class>
            <entities>
                <catalogues><!-- tag must match lowercase model file name -->
                    <table>fisheye_enquiryforms_catalogues</table>
                </catalogues>
                <quotes><!-- tag must match lowercase model file name -->
                    <table>fisheye_enquiryforms_quotes</table>
                </quotes>
                <products><!-- tag must match lowercase model file name -->
                    <table>fisheye_enquiryforms_products</table>
                </products>
            </entities>              
        </fisheye_enquiryforms_mysql4>  
    </models>

    <resources>

        <fisheye_enquiryforms_setup>
            <setup>
                <module>Fisheye_Enquiryforms</module>
            </setup>
        </fisheye_enquiryforms_setup>

    </resources>

</global>

enquiryforms.xml是

<?xml version="1.0"?>
<layout>
<adminhtml_enquiryforms_catalogues_index>
    <reference name="content">
        <block type="fisheye_enquiryforms/adminhtml_catalogues" name="enquiryforms.catalogues" />
    </reference>
</adminhtml_enquiryforms_catalogues_index>
<adminhtml_enquiryforms_products_index>
    <reference name="content">
        <block type="fisheye_enquiryforms/adminhtml_products" name="enquiryforms.products" />
    </reference>
</adminhtml_enquiryforms_products_index>
<adminhtml_enquiryforms_quotes_index>
    <reference name="content">
        <block type="fisheye_enquiryforms/adminhtml_quotes" name="enquiryforms.quotes" />
    </reference>
</adminhtml_enquiryforms_quotes_index>
</layout>

提前致谢

戴夫

Answer 1:

好了,这个乱搞的年龄后,我决定恢复旧模块我已经停用在系统>配置>高级前阵子比较CONFIGS,才发现我的学院之一和蔼一直在和禁用所有的发展模块上做一个第三方模块发出一些测试。 这可以解释为什么它只是停止渲染和也是为什么我越来越没有错误。 我想昨天感谢哈维尔所有帮助和appologise我Megento noobness笑:)另一个Magento的教训!

谢谢,

戴夫乙



Answer 2:

这就是我如何做到这一点,我希望它能帮助: company/modulename/Block/Adminhtml/Myblock.php

<?php
class Company_Modulename_Block_Adminhtml_Myblock extends Mage_Adminhtml_Block_Widget_Grid_Container
{
    public function __construct()
    {
        $this->_blockGroup = 'company_modulename';
        $this->_controller = 'adminhtml_mycontroller';
        $this->_headerText = 'My Block';
        parent::__construct();
        $this->_removeButton('add');
    }
}

company/modulename/Block/Adminhtml/Myblock/Grid.php

<?php
class Company_Modulename_Block_Adminhtml_Myblock_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
    public function __construct()
    {
        parent::__construct();
        $this->setId('company_myblockGrid');
        $this->setDefaultSort('entity_id');
        $this->setDefaultDir('DESC');
        $this->setSaveParametersInSession(true);
    }
    /**
     * Add custom column to the grid
     *
     */
    public function setCollection($collection)
    {
        // your stuff
        parent::setCollection($collection);
    }
    protected function _prepareCollection()
    {
       // your stuff
        return parent::_prepareCollection();
    }

    protected function _prepareColumns()
    {
        // your stuff
        return parent::_prepareColumns();
    }
}

然后,从控制器: company/modulename/controllers/Adminhtml/Mycontroller.php

public function myblockgridAction()
{
    $this->_title('My block grid');
    $this->loadLayout();
    $this->_addContent($this->getLayout()->createBlock('company_modulename/adminhtml_myblock'));
    $this->renderLayout();
}

在你的情况,如果从布局加载它,应该是相同的。



文章来源: Magento Widget Grid only fires construct
标签: php magento