Adam Moss
Adam Moss

Reputation: 5712

How to create a simple admin module grid for products in Magento?

I'm creating a very simple admin module which displays a list of products and their stock levels, and I want to present the data in a nice Magento grid. Later I will make it a form which will allow the user to update the stock via this page.

I've created the ability to show an admin phtml page with the IndexController like this:

<?php
class Creare_StockManagement_IndexController extends Mage_Adminhtml_Controller_Action
   {
    public function indexAction()
   {
    $this->loadLayout();

    $this->_addContent($this->getLayout()->createBlock('adminhtml/template')
    ->setTemplate('stockmanagement/list.phtml'));   

    $this->_setActiveMenu('stock_menu/stockmanagement');

    $this->renderLayout();
  }
}

My list.phtml page contains a basic table and product list that I have echoed using the collection. I've been reading tutorials on the Internet about how to use Magento's grid system, but probably being a bit out of my depth I'm struggling to complete the next stage.

Can anyone point me in the right direction in terms of what files I need? The Module name is StockManagement. I feel like I'm very close, I just lack the understanding at this stage to piece it all together.

Anyway, any help would be much appreciated.

Upvotes: 0

Views: 4339

Answers (1)

clockworkgeek
clockworkgeek

Reputation: 37700

When I last used it, Module Creator makes an admin page with a grid - although I haven't used it recently so am less sure what it currently does.

You won't need a template since the grid and grid container widgets already have flexible templates built in.

Upvotes: 1

Related Questions