0

I'm trying to create some custom inventory reports without luck. I started with this tutorial. Creating new completely custom reports

I have followed everything to the letter and started over several times just to be sure I didn't miss something, but still get a blank page. All the files are loading except everything under Block.

There are a few things about the config files I still don't understand, so can someone tell me if everything looks good here:

My Company is Gallerypad and Namespace is Inventory

app/code/local/Gallerypad/Inventory/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Gallerypad_Inventory>
            <version>0.1.0</version>
        </Gallerypad_Inventory>
    </modules>

    <admin>
        <routers>
            <inventory>
                <use>admin</use>
                <args>
                    <module>Gallerypad_Inventory</module>
                    <frontName>inventory</frontName>
                </args>
            </inventory>
        </routers>
    </admin>

    <adminhtml>
        <menu>
            <report>
                <children>
                    <inventory translate="title" module="inventory">
                        <title>Inventory Report</title>
                        <action>inventory/adminhtml_inventory</action>
                    </inventory>
                </children>
            </report>
        </menu>
        <acl>
            <resources>
                <all>
                    <title>Allow Everything</title>
                </all>
                <admin>
                    <children>
                        <report>
                            <children>
                                <inventory translate="title" module="inventory">
                                    <title>Inventory Report</title>
                                    <action>inventory/adminhtml_inventory</action>
                                </inventory>
                            </children>
                        </report>
                    </children>
                </admin>
            </resources>
        </acl>
        <layout>
            <updates>
                <inventory>
                    <file>inventory.xml</file>
                </inventory>
            </updates>
        </layout>
    </adminhtml>
    <global>
        <models>
            <inventory>
                <class>Gallerypad_Inventory_Model</class>
                <resourceModel>inventory</resourceModel>
            </inventory>
        </models>
        <resources>
            <inventory_setup>
                <setup>
                    <module>Gallerypad_Inventory</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </inventory_setup>
            <inventory_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </inventory_write>
            <inventory_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </inventory_read>
        </resources>
        <blocks>
            <inventory>
                <class>Gallerypad_Inventory_Block</class>
            </inventory>
        </blocks>
        <helpers>
            <inventory>
                <class>Gallerypad_Inventory_Helper</class>
            </inventory>
        </helpers>
    </global>
</config>

app/design/adminhtml/default/default/layout/inventory.xml

<?xml version="1.0"?>
<layout version="0.1.0">
    <inventory_adminhtml_inventory_index>
        <reference name="content">
            <block type="inventory/adminhtml_inventory" name="inventory" />
        </reference>
    </inventory_adminhtml_inventory_index>
</layout>

app/code/local/Gallerypad/Inventory/Block/Inventory.php

<?php
class Gallerypad_Inventory_Block_Inventory extends Mage_Core_Block_Template {
    public function _prepareLayout() {
        var_dump(debug_backtrace());
        return parent::_prepareLayout();
    }

    public function getInventory()  {
        if (!$this->hasData('inventory')) 
        {
            $this->setData('inventory', Mage::registry('inventory'));
        }
        return $this->getData('inventory');
    } 
}

app/code/local/Gallerypad/Inventory/Block/Adminhtml/Inventory.php

(there was confusion in orginial post about Adminhtml or adminhtml, so I've tried both ways)

<?php
class Gallerypad_Inventory_Block_Adminhtml_Inventory extends Mage_Adminhtml_Block_Widget_Grid_Container {
    public function __construct() {
        $this->_controller = 'adminhtml_inventory';
        $this->_blockGroup = 'inventory';
        $this->_headerText = Mage::helper('inventory')->__('Inventory Report');
        parent::__construct();
        $this->_removeButton('add');
    }
}

app/code/local/Gallerypad/Inventory/Block/Adminhtml/Inventory/Grid.php

<?php
class Gallerypad_Inventory_Block_Adminhtml_Inventory_Grid extends Mage_Adminhtml_Block_Report_Grid {
    public function __construct() {
        parent::__construct();
        $this->setId('inventoryGrid');
        $this->setDefaultSort('created_at');
        $this->setDefaultDir('ASC');
        $this->setSaveParametersInSession(true);
        $this->setSubReportSize(false);
    }

    protected function _prepareCollection() {
        parent::_prepareCollection();
        $this->getCollection()->initReport('inventory/inventory');
        return $this;
    }

    protected function _prepareColumns() {
        $this->addColumn('ordered_qty', array(
            'header'    =>Mage::helper('reports')->__('Quantity Ordered'),
            'align'     =>'right',
            'index'     =>'ordered_qty',
            'total'     =>'sum',
            'type'      =>'number'
        ));
        $this->addColumn('item_id', array(
            'header' => Mage::helper('inventory')->__('Item ID'),
            'align' => 'right',
            'index' => 'item_id',
            'type'  => 'number',
            'total' => 'sum',
        ));
        $this->addExportType('*/*/exportCsv', Mage::helper('inventory')->__('CSV'));
        $this->addExportType('*/*/exportXml', Mage::helper('inventory')->__('XML'));
        return parent::_prepareColumns();
    }

    public function getRowUrl($row) {
        return false;
    }

    public function getReport($from, $to) {
        if ($from == '') {
            $from = $this->getFilter('report_from');
        }
        if ($to == '') {
            $to = $this->getFilter('report_to');
        }
        $totalObj = Mage::getModel('reports/totals');
        $totals = $totalObj->countTotals($this, $from, $to);
        $this->setTotals($totals);
        $this->addGrandTotals($totals);
        return $this->getCollection()->getReport($from, $to);
    }
}

The other parts from the original post seem to be working, so I won't repost. Any help would be very appreciated as I've got over 20 hours trying different things.

0

Found my problem and it was me being stupid. Thought I had all cache turned off, but Blocks HTML output was still enabled. Flushed Magento Cache and everything started working.

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.