1

I am working on a custom magento admin backend module, which will have a grid with items that can be added/edited. This is my module structure:

/Mycompany/
---/Mymodule/
-------/Block/
-----------/Adminhtml
--------------/Manageskumappings.php
--------------/Manageskumappings/
-----------------/Grid.php
-----------------/Edit.php
-----------------/Edit/
--------------------/Form.php
-------/controllers/
-----------/Adminhtml
--------------/ManageskumappingsController.php
-------/etc/
-------/Helper/
-------/Model/
-------/sql/

This is my module's config.xml:

<?xml version="1.0"?>
<config>

    <!-- Module Info -->
    <modules>
        <Mycompany_Mymodule>
            <version>2.0.0</version>
        </Mycompany_Mymodule>
    </modules>

    <!-- Module Globals -->
    <global>

        <!-- Register Helper -->
        <helpers>
            <mycompany_mymodule>
                <class>Mycompany_Mymodule_Helper</class>
            </mycompany_mymodule>
        </helpers>

        <!-- Register Models -->
        <models>
            <mycompany_mymodule>
                <class>Mycompany_Mymodule_Model</class>
                <resourceModel>mycompany_mymodule_mysql4</resourceModel>
            </mycompany_mymodule>
            <mycompany_mymodule_mysql4>
                <class>Mycompany_Mymodule_Model_Mysql4</class>
                <entities>
                    <skumappings>
                        <table>icw_ic_skumappings</table>
                    </skumappings>
                </entities>
            </mycompany_mymodule_mysql4>
        </models>

        <!-- Register Resource -->
        <resources>
            <mycompany_mymodule_setup>
                <setup>
                    <module>Mycompany_Mymodule</module>
                </setup>
            </mycompany_mymodule_setup>
        </resources>

    </global>

    <!-- Admin Router -->
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <Mycompany_Mymodule after="Mage_Adminhtml">Mycompany_Mymodule_Adminhtml</Mycompany_Mymodule>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>

    <!-- Admin Layout -->
    <adminhtml>
        <layout>
            <updates>
                <mycompany_mymodule>
                    <file>mycompany/mymodule.xml</file>
                </mycompany_mymodule>
            </updates>
        </layout>
    </adminhtml>

</config>

and this is my adminhtml.xml for the module:

<?xml version="1.0"?>
<config>

    <!-- Menu Setup -->
    <menu>
        <mycompany translate="title" module="mycompany_mymodule">
            <title>Infinite:Connect v2</title>
            <sort_order>0</sort_order>
            <children>
                <mycompany_mymodule_manageskumappings>
                    <title>Manage SKU Mappings</title>
                    <sort_order>1</sort_order>
                    <action>adminhtml/manageskumappings</action>
                </mycompany_mymodule_manageskumappings>
            </children>
        </mycompany>
    </menu>

    <!-- Access Control List -->
    <acl>
        <resources>
            <admin>
                <children>                
                    <mycompany translate="title" module="mycompany_mymodule">
                        <title>My Module</title>
                        <sort_order>1</sort_order>
                        <children>
                            <manageskumappings>
                                <title>Manage SKU Mappings</title>
                                <sort_order>1</sort_order>
                            </manageskumappings>
                        </children>
                    </mycompany>
                </children>
            </admin>
        </resources>
    </acl>

</config>

I have created the following layout file:

app/design/adminhtml/default/default/layout/mycompany/mymodule.xml

With the following definition:

<?xml version="1.0"?>
<layout>

    <!-- Manage SKU Mappings -->
    <adminhtml_manageskumappings_index>
        <reference name="content">
            <block type="mycompany_mymodule/adminhtml_manageskumappings" name="mycompany_mymodule_manageskumappings" />
        </reference>
    </adminhtml_manageskumappings_index>

</layout>

This is my grid controller:

app/code/community/Mycompany/Mymodule/controllers/Adminhtml/ManageskumappingsController.php

With the following code:

<?php

class Mycompany_Mymodule_Adminhtml_ManageskumappingsController extends Mage_Adminhtml_Controller_Action
{
    protected function _isAllowed()
    {
        return Mage::getSingleton('admin/session')
            ->isAllowed('mycompany/manageskumappings');
    }

    protected function _initAction()
    {
        $this->loadLayout()
            ->_setActiveMenu('mycompany/mycompany_mymodule_manageskumappings')
            ->_title('Manage SKU Mappings');

        return $this;
    }

    public function indexAction()
    {  
        $this->_initAction()
            ->renderLayout();
    }

    // ... Snipped ...

I've uploaded the code and the db migrated and the menu appears. When I go to the menu "Mymodule -> Manage SKU Mappings" I see a blank page.

I went to look at var/log/exception.log and I see the following:

exception 'Mage_Core_Exception' with message 'Invalid block type: Mage_Mycompany_Mymodule_Block_Adminhtml_Manageskumappings' in /var/www/public_html/app/Mage.php:595

Any idea what might be wrong?

3

You should declare also in config.xml under <config> -> <global> node the following:

<blocks>
   <mycompany_mymodule>
      <class>Mycompany_Mymodule_Block</class>
   </mycompany_mymodule>
</blocks>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.