Creating an 'admin module' for Magento can eat up your head if you are doing it for the first time. But believe me, after reading this tutorial you will feel it like a child's play. Here I will tell you the simplest way of creating an admin module in Magento. This tutorial assumes that you are already familiar with creating simple modules in Magento. If you are not, please read this tutorial.
Download Magento Backend Module
Namespace : Company
Module Name : Web
|–Web/
| |–Block/
| |–controllers/
| |–etc/
| |–Helper/
| |–sql/
|
Download Magento Backend Module
Module Name : Web
Step 1: Declare your shell module and it’s code pool
Create an xml file /app/etc/modules/Company_Web.xml (You can use any name, even you can use a single file to declare number of modules).<?xml version="1.0"?>
<config>
<modules>
<Company_Web>
<active>true</active>
<codePool>local</codePool>
</Company_Web>
</modules>
</config>
Step 2:
Create the basic directory structure under /app/code/core/local/ :-
Company/|–Web/
| |–Block/
| |–controllers/
| |–etc/
| |–Helper/
| |–sql/
|
Step 3:
Write the front controller in app\code\local\Company\Web\controllers\IndexController.php
<?php
class Company_Web_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
Step 4:
Write your backend module controller in app\code\local\Company\Web\controllers\Adminhtml\WebController.php
<<?php
class Company_Web_Adminhtml_WebController extends Mage_Adminhtml_Controller_action
{
protected function _initAction() {
$this->loadLayout()
->_setActiveMenu('web/items')
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
return $this;
}
public function indexAction() {
$this->_initAction()
->renderLayout();
}
public function editAction() {
$id = $this->getRequest()->getParam('id');
$model = Mage::getModel('web/web')->load($id);
if ($model->getId() || $id == 0) {
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
if (!empty($data)) {
$model->setData($data);
}
Mage::register('web_data', $model);
$this->loadLayout();
$this->_setActiveMenu('web/items');
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
$this->_addContent($this->getLayout()->createBlock('web/adminhtml_web_edit'))
->_addLeft($this->getLayout()->createBlock('web/adminhtml_web_edit_tabs'));
$this->renderLayout();
} else {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('web')->__('Item does not exist'));
$this->_redirect('*/*/');
}
}
public function newAction() {
$this->_forward('edit');
}
public function saveAction() {
if ($data = $this->getRequest()->getPost()) {
if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
try {
/* Starting upload */
$uploader = new Varien_File_Uploader('filename');
// Any extention would work
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
$uploader->setAllowRenameFiles(false);
// Set the file upload mode
// false -> get the file directly in the specified folder
// true -> get the file in the product like folders
// (file.jpg will go in something like /media/f/i/file.jpg)
$uploader->setFilesDispersion(false);
// We set media as the upload dir
$path = Mage::getBaseDir('media') . DS ;
$uploader->save($path, $_FILES['filename']['name'] );
} catch (Exception $e) {
}
//this way the name is saved in DB
$data['filename'] = $_FILES['filename']['name'];
}
$model = Mage::getModel('web/web');
$model->setData($data)
->setId($this->getRequest()->getParam('id'));
try {
if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
$model->setCreatedTime(now())
->setUpdateTime(now());
} else {
$model->setUpdateTime(now());
}
$model->save();
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('web')->__('Item was successfully saved'));
Mage::getSingleton('adminhtml/session')->setFormData(false);
if ($this->getRequest()->getParam('back')) {
$this->_redirect('*/*/edit', array('id' => $model->getId()));
return;
}
$this->_redirect('*/*/');
return;
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
Mage::getSingleton('adminhtml/session')->setFormData($data);
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
return;
}
}
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('web')->__('Unable to find item to save'));
$this->_redirect('*/*/');
}
public function deleteAction() {
if( $this->getRequest()->getParam('id') > 0 ) {
try {
$model = Mage::getModel('web/web');
$model->setId($this->getRequest()->getParam('id'))
->delete();
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
$this->_redirect('*/*/');
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
}
}
$this->_redirect('*/*/');
}
public function massDeleteAction() {
$webIds = $this->getRequest()->getParam('web');
if(!is_array($webIds)) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
} else {
try {
foreach ($webIds as $webId) {
$web = Mage::getModel('web/web')->load($webId);
$web->delete();
}
Mage::getSingleton('adminhtml/session')->addSuccess(
Mage::helper('adminhtml')->__(
'Total of %d record(s) were successfully deleted', count($webIds)
)
);
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
}
}
$this->_redirect('*/*/index');
}
public function massStatusAction()
{
$webIds = $this->getRequest()->getParam('web');
if(!is_array($webIds)) {
Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
} else {
try {
foreach ($webIds as $webId) {
$web = Mage::getSingleton('web/web')
->load($webId)
->setStatus($this->getRequest()->getParam('status'))
->setIsMassupdate(true)
->save();
}
$this->_getSession()->addSuccess(
$this->__('Total of %d record(s) were successfully updated', count($webIds))
);
} catch (Exception $e) {
$this->_getSession()->addError($e->getMessage());
}
}
$this->_redirect('*/*/index');
}
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
{
$response = $this->getResponse();
$response->setHeader('HTTP/1.1 200 OK','');
$response->setHeader('Pragma', 'public', true);
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
$response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
$response->setHeader('Last-Modified', date('r'));
$response->setHeader('Accept-Ranges', 'bytes');
$response->setHeader('Content-Length', strlen($content));
$response->setHeader('Content-type', $contentType);
$response->setBody($content);
$response->sendResponse();
die;
}
}
Step 5:
Write the frontend block file in app\code\local\Company\Web\Block\Web.php
<?php
class Company_Web_Block_Web extends Mage_Core_Block_Template
{
public function _prepareLayout()
{
return parent::_prepareLayout();
}
public function getWeb()
{
if (!$this->hasData('web')) {
$this->setData('web', Mage::registry('web'));
}
return $this->getData('web');
}
}
Step 6: Now write the following file- app\code\local\Company\Web\Block\Adminhtml\Web.php
<?php
class Company_Web_Block_Adminhtml_Web extends Mage_Adminhtml_Block_Widget_Grid_Container
{
public function __construct()
{
$this->_controller = 'adminhtml_web';
$this->_blockGroup = 'web';
$this->_headerText = Mage::helper('web')->__('Item Manager');
$this->_addButtonLabel = Mage::helper('web')->__('Add Item');
parent::__construct();
}
}
Step 7: Now write the following file- app\code\local\Company\Web\Block\Adminhtml\Web\Grid.php
<?php
class Company_Web_Block_Adminhtml_Web_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
public function __construct()
{
parent::__construct();
$this->setId('webGrid');
$this->setDefaultSort('web_id');
$this->setDefaultDir('ASC');
$this->setSaveParametersInSession(true);
}
protected function _prepareCollection()
{
$collection = Mage::getModel('web/web')->getCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
$this->addColumn('web_id', array(
'header' => Mage::helper('web')->__('ID'),
'align' =>'right',
'width' => '50px',
'index' => 'web_id',
));
$this->addColumn('title', array(
'header' => Mage::helper('web')->__('Title'),
'align' =>'left',
'index' => 'title',
));
/*
$this->addColumn('content', array(
'header' => Mage::helper('web')->__('Item Content'),
'width' => '150px',
'index' => 'content',
));
*/
$this->addColumn('status', array(
'header' => Mage::helper('web')->__('Status'),
'align' => 'left',
'width' => '80px',
'index' => 'status',
'type' => 'options',
'options' => array(
1 => 'Enabled',
2 => 'Disabled',
),
));
$this->addColumn('action',
array(
'header' => Mage::helper('web')->__('Action'),
'width' => '100',
'type' => 'action',
'getter' => 'getId',
'actions' => array(
array(
'caption' => Mage::helper('web')->__('Edit'),
'url' => array('base'=> '*/*/edit'),
'field' => 'id'
)
),
'filter' => false,
'sortable' => false,
'index' => 'stores',
'is_system' => true,
));
$this->addExportType('*/*/exportCsv', Mage::helper('web')->__('CSV'));
$this->addExportType('*/*/exportXml', Mage::helper('web')->__('XML'));
return parent::_prepareColumns();
}
protected function _prepareMassaction()
{
$this->setMassactionIdField('web_id');
$this->getMassactionBlock()->setFormFieldName('web');
$this->getMassactionBlock()->addItem('delete', array(
'label' => Mage::helper('web')->__('Delete'),
'url' => $this->getUrl('*/*/massDelete'),
'confirm' => Mage::helper('web')->__('Are you sure?')
));
$statuses = Mage::getSingleton('web/status')->getOptionArray();
array_unshift($statuses, array('label'=>'', 'value'=>''));
$this->getMassactionBlock()->addItem('status', array(
'label'=> Mage::helper('web')->__('Change status'),
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
'additional' => array(
'visibility' => array(
'name' => 'status',
'type' => 'select',
'class' => 'required-entry',
'label' => Mage::helper('web')->__('Status'),
'values' => $statuses
)
)
));
return $this;
}
public function getRowUrl($row)
{
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
}
}
Step 8: Now write the following file- app\code\local\Company\Web\Block\Adminhtml\Web\Edit.php
<php
class Company_Web_Block_Adminhtml_Web_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{
public function __construct()
{
parent::__construct();
$this->_objectId = 'id';
$this->_blockGroup = 'web';
$this->_controller = 'adminhtml_web';
$this->_updateButton('save', 'label', Mage::helper('web')->__('Save Item'));
$this->_updateButton('delete', 'label', Mage::helper('web')->__('Delete Item'));
$this->_addButton('saveandcontinue', array(
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
'onclick' => 'saveAndContinueEdit()',
'class' => 'save',
), -100);
$this->_formScripts[] = "
function toggleEditor() {
if (tinyMCE.getInstanceById('web_content') == null) {
tinyMCE.execCommand('mceAddControl', false, 'web_content');
} else {
tinyMCE.execCommand('mceRemoveControl', false, 'web_content');
}
}
function saveAndContinueEdit(){
editForm.submit($('edit_form').action+'back/edit/');
}
";
}
public function getHeaderText()
{
if( Mage::registry('web_data') && Mage::registry('web_data')->getId() ) {
return Mage::helper('web')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('web_data')->getTitle()));
} else {
return Mage::helper('web')->__('Add Item');
}
}
}
Step 9:
Create the config file as app\code\local\Company\Web\etc\config.xml
<?xml version="1.0"?>
<config>
<modules>
<Company_Web>
<version>0.1.0</version>
</Company_Web>
</modules>
<frontend>
<routers>
<web>
<use>standard</use>
<args>
<module>Company_Web</module>
<frontName>web</frontName>
</args>
</web>
</routers>
<layout>
<updates>
<web>
<file>web.xml</file>
</web>
</updates>
</layout>
</frontend>
<admin>
<routers>
<web>
<use>admin</use>
<args>
<module>Company_Web</module>
<frontName>web</frontName>
</args>
</web>
</routers>
</admin>
<adminhtml>
<menu>
<web module="web">
<title>Web</title>
<sort_order>71</sort_order>
<children>
<items module="web">
<title>Manage Items</title>
<sort_order>0</sort_order>
<action>web/adminhtml_web</action>
</items>
</children>
</web>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<Company_Web>
<title>Web Module</title>
<sort_order>10</sort_order>
</Company_Web>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<web>
<file>web.xml</file>
</web>
</updates>
</layout>
</adminhtml>
<global>
<models>
<web>
<class>Company_Web_Model</class>
<resourceModel>web_mysql4</resourceModel>
</web>
<web_mysql4>
<class>Company_Web_Model_Mysql4</class>
<entities>
<web>
<table>web</table>
</web>
</entities>
</web_mysql4>
</models>
<resources>
<web_setup>
<setup>
<module>Company_Web</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</web_setup>
<web_write>
<connection>
<use>core_write</use>
</connection>
</web_write>
<web_read>
<connection>
<use>core_read</use>
</connection>
</web_read>
</resources>
<blocks>
<web>
<class>Company_Web_Block</class>
</web>
</blocks>
<helpers>
<web>
<class>Company_Web_Helper</class>
</web>
</helpers>
</global>
</config>
Step 10: Now write the helper class app\code\local\Company\Web\Helper\Data.php
<?php
class Company_Web_Helper_Data extends Mage_Core_Helper_Abstract
{
}
Step 11: Create the model class for your module app\code\local\Company\Web\Model\Web.php
<?php
class Company_Web_Model_Web extends Mage_Core_Model_Abstract
{
public function _construct()
{
parent::_construct();
$this->_init('web/web');
}
}
Step 12: Now create app\code\local\Company\Web\Model\Mysql4\Web.php
<?php
class Company_Web_Model_Mysql4_Web extends Mage_Core_Model_Mysql4_Abstract
{
public function _construct()
{
// Note that the web_id refers to the key field in your database table.
$this->_init('web/web', 'web_id');
}
}
Step 13: Now create the collection class app\code\local\Company\Web\Model\Mysql4\Web\Collection.php
<?php
class Company_Web_Model_Mysql4_Web_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
public function _construct()
{
parent::_construct();
$this->_init('web/web');
}
}
Step 14: Now add the mysql setup file as app\code\local\Company\Web\sql\web_setup\mysql4-install-0.1.0.php
<?php
$installer = $this;
$installer->startSetup();
$installer->run("
-- DROP TABLE IF EXISTS {$this->getTable('web')};
CREATE TABLE {$this->getTable('web')} (
`web_id` int(11) unsigned NOT NULL auto_increment,
`title` varchar(255) NOT NULL default '',
`filename` varchar(255) NOT NULL default '',
`content` text NOT NULL default '',
`status` smallint(6) NOT NULL default '0',
`created_time` datetime NULL,
`update_time` datetime NULL,
PRIMARY KEY (`web_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
");
$installer->endSetup();
Step 15: Add the layout.xml as app\design\frontend\default\default\layout\web.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
</default>
<web_index_index>
<reference name="content">
<block type="web/web" name="web" template="web/web.phtml" />
</reference>
</web_index_index>
</layout>
Step 16: Now write the following file- app\design\adminhtml\default\default\layout\web.xml
<<?xml version="1.0"?>
<layout version="0.1.0">
<web_adminhtml_web_index>
<reference name="content">
<block type="web/adminhtml_web" name="web" />
</reference>
</web_adminhtml_web_index>
</layout>
Step 17: Finally create the template file of your module app\design\frontend\default\default\template\web\web.phtml
<?php echo "Welcome to your custom module...."; ?>


Thank you for your post. it helped me to understand how to create a modules.
ReplyDeleteAnd I read your previous post about simple module - very good post.
But I can't see the result of module in this post. I tried to verify again step by step - I see a new tab in Admin side, but the pages 'Add new' and 'Edit' do not work.
In the previous example you have shown how we can test this example. I think it would be better if you add to this post the result of this example. It very helped me.
Thank you for this post.
Hi!
ReplyDeleteThe file /etc/config.xml, has been updated. Please check if it works now. Only the page 'Add New' will work, 'Edit' is just for a demo.
Hi Friend,
DeleteI m new to magento i have create one simple extension but i don't know how to implement onepagecheckout in the module.. plz expline
Hello!
ReplyDeleteWhich version of config.xml (step8 or step 9) should be in my file?
Could you attach archive of this module, please? Or only correct config.file
Thank you
Hi anonymous!
ReplyDeleteStep8 and step9 have been updated, please take a careful reference.
The file of step9 should be renamed as adminhtml.xml instead of config.xml
It should work now, please ask if there is some problem. And I will try to attach the archive of this module as soon as possible. Keep updated.
Good luck!
hello sir
ReplyDeletei follow ur steps to create custom module in admin panel after doing this new menu link comes but page is not working please help me in this.
Even add new page is not working in this plz help me.
Waiting for ur reply
Hello,
ReplyDeleteI have my menu displayed in admin panel but when I click on "Add New" or "Edit", I have à 404 not found page error. Is it because I have nothing in My Block/AdminHtml directory?
Thanks!
Please see if all the files are at right place. This module is fully tested.
DeleteHi,
ReplyDeleteI have restart your tutorial and I have not errors!!
But, I've just the admin menu diplayed,the content is blank. My layout doesn't works Do you have any solution?
Thanks!
Hello Anonymous,
ReplyDeleteI don't see any error in this tutorial. It is possible that you are missing something. Still I will recheck the tutorial and inform you as soon as possible. Be updated.
i want to make a module realted to social networking like facebook, twitter in the backend i want to manage user info like user email, no of hits and comments how can we do that can u help me i am just beginner of magento.. please help me still waiting for your answer…
ReplyDeleteThank for your post,,,,
ReplyDeleteplease give me another example module related with social networking....
Still waiting for your response...
I'm also having the problem where the links show in the admin menu and clicking on the add new link doesn't take you to a 404 page but it just displays an empty content section :(
ReplyDelete@billy, there was a bug in the xml file. It has been fixed now. Please try the new module.
Deletei also having problem to access admin menu. its just showing 'This webpage is not found.'
ReplyDeleteplease help. thanks
Indian Developer's rocks
ReplyDeletekeep it up dude.....
the solution to solve this empty page is change
ReplyDelete"web.xml" file like this:
web_adminhtml_purchaseorder_index
reference name="content"
block type="adminhtml/template" name="purchaseorder" template="web/purchaseorder.phtml"
/reference
/web_adminhtml_purchaseorder_index
/layout
Thanks for the fix.
DeleteManaged to get menu working, however when I click "Add New" link I dont get any content in my main block! I have done what isra said. Pls Help!
ReplyDeletethe solution to solve this empty page is change
ReplyDelete"web.xml" file like this:
web_adminhtml_purchaseorder_index
reference name="content"
block type="adminhtml/template" name="purchaseorder" template="company_web/purchaseorder.phtml"
/reference
/web_adminhtml_purchaseorder_index
/layout
This works! missed company_web off template type!
David
To solve the blank page problem, I add a file web.xml in app\design\ADMINHTML\default\default\layout\ with the content:
ReplyDelete< ?xml version="1.0"? >
< layout version="0.1.0" >
< default >
< /default >
< web_adminhtml_web_index >
< reference name="content" >
< block type="web/adminhtml_web" name="web" / >
< /reference >
< /web_adminhtml_web_index >
< /layout >
Thanks for the fix.
DeleteThe download file has been updated, Please try the new download.
I am not able to display the page when i am clicking on manage items option from the Web menu so please let me know what kinds of changes i have to made so that it will display the information which are there in manage items page...
ReplyDeleteI hope i get reply as soon as possible
I can't see anything when I am clicking on manage items options at admin side.
ReplyDeleteSo Please, Let me know about what kind of changes i have to made.
Hopping for a favorable reply as soon as possible.
Thanks... good post..
ReplyDeleteHow to create a form in that new page? can you guide me....
i am also getting same problem when i logged in and click on the manage item then blank page appears....
ReplyDeletePlease help me
Thanks in advance
I did all thing as say exactly but I didn't get any option in admin end Please guide me It necessery........thanks
ReplyDelete@Vishnu, There was a bug in the xml layout file. It has been fixed now. Please download the new module and try again.
DeleteThanks.
I cleared the cache of magento many times. Still it displays blank page when I clicked on sub menu 'manage items'. I think, I loose my hours following this module.
ReplyDelete@Naleen, There was a bug in the xml layout file. It has been fixed now. Please download the new module and try again.
DeleteThanks.
Hi,
ReplyDeleteIs it working with Magento ver. 1.6.0.0. bcoz when I tried by simply copy pasting your code in app/ folder, it is not showing the tab "Web", what could be the issue?
Which link I will see in admin. I can't see any links in admin. What is the issue?
ReplyDeleteThere are a number of things in this tutorial I don't understand. First; step 2. Why create directories in /app/code/core/local/, when all the files in the following steps are stored in /app/code/local/? And if this is an error, why only create a few directories, when you need to create more directories following the steps anyways?
ReplyDeleteWhy use different indentation among the files, e.g.
function {
..
}
function
{
..
}
And 1-space, 2-space indentation, etc.
Also, why the very generic name 'web'. When I want to name my module Indiana_Jones instead of Company_Web, do I need to replace ALL the words with 'web' in the files with 'jones', same for the directories? Since Magento also has some function with 'web', it isn't clear to me on first sight, which would be with a different name.
I've followed your tutorial 3 times because I can't get it to work, nothing shows up. I'm working with Magento 1.6.1
Thank you very much. It was really useful.
ReplyDeleteusing 1.6.2 i got the menu to work (i had to create a Grid directory under Blocks/Adminhtml and create a Grid.php file containing only the class name), i can click the Menu Items link in the admin menu which displays a page saying 'Item Manager' along with a button saying add item, however clicking this button produces a 404 (page not found) error. How is this page generated? the url the link produces changed from having /index/key/{key} to /new/key/{key}
ReplyDeleteyour downloaded product is not working
ReplyDelete@Chirag, There was a bug in the xml layout file. It has been fixed now. Please download the new module and try again.
DeleteThanks.
Hello i am using magento 1.5.0.1. It displaying web menu in top but not display anything when i click on Manage Items... what should i do?
ReplyDeleteThere was a bug in the xml layout file. It has been fixed now. Please download the new module and try again.
DeleteThanks.
Hi Dear,
ReplyDeleteThe Article is very good to understand the structure of module in magento but the given attachement is not working on newer version. I have tried it on 1.6 version.
and i followed the steps given in this article to create my own admin module but it wont work i can see menu but on clicking on it is showing me blank page .
please help me i m novice to magento and didnt got any good help on this .
your help is appreciable.
Hi All,
ReplyDeleteThe module and the zip file has been updated for proper working.
Thanks.
Hi Arvin,
ReplyDeleteI just checked your module. I downloaded it but I have an issue with error about the database "There has been an error processing your request". Should I create the database web or as I see your code inside mysql4-install-0.1.0.php should create it itself. When I check the log record it says that Base table or view not found.
Thanks for your help !
Kind regards,
naim
Hi All,
ReplyDeleteThere was a bug in the xml layout file. It has been fixed now. Please download the new module and try again.
Thanks.
hi to the author. thanks for the new model fixed.
ReplyDeletekeep up the good work.
I just downloaded this, and i am getting the database error
ReplyDeletea:5:{i:0;s:105:"SQLSTATE[42S02]: Base table or view not found: 1146 Table 'e556895_edu_main_website_db.web' doesn't exist";i:1;s:5642:"#0 /home/e556895/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /home/e556895/public_html/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /home/e556895/public_html/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#3 /home/e556895/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT COUNT(*)...', Array)
#4 /home/e556895/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(389): Zend_Db_Adapter_Pdo_Abstract->query('SELECT COUNT(*)...', Array)
#5 /home/e556895/public_html/lib/Zend/Db/Adapter/Abstract.php(825): Varien_Db_Adapter_Pdo_Mysql->query(Object(Varien_Db_Select), Array)
#6 /home/e556895/public_html/lib/Varien/Data/Collection/Db.php(217): Zend_Db_Adapter_Abstract->fetchOne(Object(Varien_Db_Select), Array)
#7 /home/e556895/public_html/lib/Varien/Data/Collection.php(225): Varien_Data_Collection_Db->getSize()
#8 /home/e556895/public_html/lib/Varien/Data/Collection.php(211): Varien_Data_Collection->getLastPageNumber()
#9 /home/e556895/public_html/lib/Varien/Data/Collection/Db.php(476): Varien_Data_Collection->getCurPage()
#10 /home/e556895/public_html/lib/Varien/Data/Collection/Db.php(518): Varien_Data_Collection_Db->_renderLimit()
#11 /home/e556895/public_html/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php(526): Varien_Data_Collection_Db->load()
#12 /home/e556895/public_html/app/code/local/Company/Web/Block/Adminhtml/Web/Grid.php(18): Mage_Adminhtml_Block_Widget_Grid->_prepareCollection()
and so on?
any ideas?
@Stefferrs, It seems that the database table for the module was not created. It may be due to permission problems or so. Please create table 'web' in your DB and it will be working.
DeleteThanks.
Hello, i am having trouble with the database, when i got to web --> manage items
ReplyDeletei am getting this database error
a:5:{i:0;s:105:"SQLSTATE[42S02]: Base table or view not found: 1146 Table 'e556895_edu_main_website_db.web' doesn't exist";i:1;s:5642:"#0 /home/e556895/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /home/e556895/public_html/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /home/e556895/public_html/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#3 /home/e556895/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT COUNT(*)...', Array)
#4 /home/e556895/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(389): Zend_Db_Adapter_Pdo_Abstract->query('SELECT COUNT(*)...', Array)
#5 /home/e556895/public_html/lib/Zend/Db/Adapter/Abstract.php(825): Varien_Db_Adapter_Pdo_Mysql->query(Object(Varien_Db_Select), Array)
#6 /home/e556895/public_html/lib/Varien/Data/Collection/Db.php(217): Zend_Db_Adapter_Abstract->fetchOne(Object(Varien_Db_Select), Array)
#7 /home/e556895/public_html/lib/Varien/Data/Collection.php(225): Varien_Data_Collection_Db->getSize()
#8 /home/e556895/public_html/lib/Varien/Data/Collection.php(211): Varien_Data_Collection->getLastPageNumber()
#9 /home/e556895/public_html/lib/Varien/Data/Collection/Db.php(476): Varien_Data_Collection->getCurPage()
#10 /home/e556895/public_html/lib/Varien/Data/Collection/Db.php(518): Varien_Data_Collection_Db->_renderLimit()
#11 /home/e556895/public_html/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php(526): Varien_Data_Collection_Db->load()
#12 /home/e556895/public_html/app/code/local/Company/Web/Block/Adminhtml/Web/Grid.php(18): Mage_Adminhtml_Block_Widget_Grid->_prepareCollection()
any ideas why?
I just downloaded and copied .. working fine .. thank you.. Arvind
ReplyDeletethanks arvin..it works for now..
ReplyDeleteHi there,
ReplyDeleteIt works like a gem.
Can you please tell me how to show the data in frontend?
Thanks!
Hi Arvind..
ReplyDeleteit is not working with ver. 1.7.0.0. even the menu is not visible. i have just copied your code, cleared cache.. any idea? please help..
thanks in advance.
i am using latest version(Magento ver. 1.7.0.1) i have copied all file to the appropriate folders but its not showing any menu in admin ..
ReplyDeleteregards
Hi Arvind,
ReplyDeleteI download the module and installed and Its working fine. But the problem is when I was creating another Admin User and assigning the custom access to that account then Its not allowing me to give the access to that Role.
Even I dont see the module name in the list to choose and assign the access.
When I was using the direct URL to access this module( Acoount having Limited permissions ) Its redirect me to the Dashboard.
Thanks
Mahak
@Vipin, I have never tested this thing. This is really good point indeed. I will see to it and get back to you ASAP.
DeleteThanks.
Thanks Arvind, at least you get time to check my request :)
DeleteI am waiting for solution soon.
Thanks
Mahak
Arvind, Did you get time to check the issue?
DeleteThanks
Mahak
Hi Arvind,
DeletePlease let me know If the above issue is fixed?
( Allowing the user to access this module. )
And let me know the steps.
Thanks in advance.
Mahak
@Arvind, Please let me know If thats possible in the module to allow the access the permission to the user?
DeleteThanks
Mahak
@Arvind
DeleteI resolved the issue :)
http://vipin2050.blogspot.in/2013/06/how-to-set-permission-on-custom-module.html
Thanks
Mahak
Hi Arvind,
ReplyDeleteI downloaded it just now but it shows a blank page, no error on the logs or on the page,
my magento version is 1.6.2.0, not sure where to check and change.. :(
Thanks!
Chris
I think you should clean the cache, logout and login if you have not done it.
DeleteI just followed the same steps and its working for me ....thanx its really g8 tutorial
ReplyDeletegr8 tutorial , Its work for me....
ReplyDeleteThanks mate! good job! ;)
ReplyDeleteThanks mate! good job! ;)
ReplyDeleteGreat Job , There is an issues with this module . It doesnt show up in giving user role list to give permession to a certian admin role . It would be great if you can sort it out .
ReplyDeleteHere is the solution:
Delete/app/code/local///etc/config.xml
Change the
...
to
...
Follow the url for detailed explanation:
http://vipin2050.blogspot.in/2013/06/how-to-set-permission-on-custom-module.html
Hi Arvind
ReplyDeleteCan you tell me the use of
Step 10: Now write the helper class app\code\local\Company\Web\Helper\Data.php
and
Step 6: Now write the following file- app\code\local\Company\Web\Block\Adminhtml\Web.php
because i want to know about its necessity
Thanks
Very Nice Thanks
ReplyDeleteIt Was realy Very nice and exactly that we wants
ReplyDeleteThanks Yaar !!!
ReplyDeleteVery Nice Tutorial ...
Got Executed Successfully !!!
This comment has been removed by the author.
ReplyDeleteHi,
ReplyDeleteI hvae downloaded the module and followed it. But i am not able to see even menu tab in admin.
Plz help me to solve this issue...
Thanks in advance.
Hi Arvind
ReplyDeleteI followed the steps and it executed successfully...
Thanks for Publishing it...:)
Now, please can you tell me, how to display the added content in front end.
Please guide me on it ASAP
Hi Arvind
ReplyDeleteI followed these steps and it is working ...
Thanks for publishing this tutorial...:)
Now, please can you guide me how to displayed added content in frontend..?
Please guide me on it ASAP.
@Geetika, you need to use the models and fetch the data through models to show on frontend.
DeleteThanks for your reply..:)
ReplyDeleteAs I am new to magento.is it possible for you to tell me in detail?
If possible then please...
Thanks in advance.
To access the data you need to create the model object as:
Delete$model = Mage::getModel('web/web')
$data = $model->getCollection()->getData();
print_r($data);
You must study models in detail to access data in more details.
Hi Arvind,
ReplyDeleteThanks...But i didn't get desired results.
Please let me know how to resolve the error,
ReplyDeleteThanks in advance :-)
( ! ) SCREAM: Error suppression ignored for
( ! ) Fatal error: Class 'Company_Web_Helper_Data' not found in D:\wamp\www\magento\app\Mage.php on line 546
Call Stack
# Time Memory Function Location
1 0.0012 379472 {main}( ) ..\index.php:0
2 0.0801 17441160 Mage::run( ) ..\index.php:87
3 0.0819 17505120 Mage_Core_Model_App->run( ) ..\Mage.php:683
4 0.1175 18633712 Mage_Core_Controller_Varien_Front->dispatch( ) ..\__default.php:20061
5 0.1206 18639048 Mage_Core_Controller_Varien_Router_Standard->match( ) ..\__default.php:17484
6 0.1273 18832432 Mage_Core_Controller_Varien_Action->dispatch( ) ..\__default.php:17927
7 0.6949 24368312 Mage_Adminhtml_DashboardController->indexAction( ) ..\__default.php:13582
8 0.9025 31962064 Mage_Core_Controller_Varien_Action->renderLayout( ) ..\DashboardController.php:43
9 0.9028 31963008 Mage_Core_Model_Layout->getOutput( ) ..\__default.php:13553
10 0.9028 31963056 Mage_Core_Block_Abstract->toHtml( ) ..\__default.php:27393
11 0.9030 31963200 Mage_Adminhtml_Block_Template->_toHtml( ) ..\__default.php:2518
12 0.9031 31963200 Mage_Core_Block_Template->_toHtml( ) ..\Mage_Adminhtml_Block_Template.php:81
13 0.9031 31963200 Mage_Core_Block_Template->renderView( ) ..\__default.php:3268
14 0.9036 31963288 Mage_Core_Block_Template->fetchView( ) ..\__default.php:3254
15 0.9042 32031768 include( 'D:\wamp\www\magento\app\design\adminhtml\default\default\template\page.phtml' ) ..\__default.php:3223
16 0.9521 32595968 Mage_Core_Block_Abstract->getChildHtml( ) ..\page.phtml:53
17 0.9522 32596032 Mage_Core_Block_Abstract->_getChildHtml( ) ..\__default.php:2181
18 0.9522 32596032 Mage_Core_Block_Abstract->toHtml( ) ..\__default.php:2237
19 0.9526 32596312 Mage_Adminhtml_Block_Template->_toHtml( ) ..\__default.php:2518
20 0.9527 32596312 Mage_Core_Block_Template->_toHtml( ) ..\Mage_Adminhtml_Block_Template.php:81
21 0.9527 32596312 Mage_Core_Block_Template->renderView( ) ..\__default.php:3268
22 0.9532 32596408 Mage_Core_Block_Template->fetchView( ) ..\__default.php:3254
23 0.9539 32642736 include( 'D:\wamp\www\magento\app\design\adminhtml\default\default\template\page\menu.phtml' ) ..\__default.php:3223
24 0.9539 32642736 Mage_Adminhtml_Block_Page_Menu->getMenuArray( ) ..\menu.phtml:30
25 0.9539 32642736 Mage_Adminhtml_Block_Page_Menu->_buildMenuArray( ) ..\Mage_Adminhtml_Block_Page_Menu.php:98
26 1.1353 34312520 Mage_Adminhtml_Block_Page_Menu->_getHelperValue( ) ..\Mage_Adminhtml_Block_Page_Menu.php:154
27 1.1353 34313008 Mage::helper( ) ..\Mage_Adminhtml_Block_Page_Menu.php:119
Hi Arvind
ReplyDeleteCan you tell me the use of
Step 10: Now write the helper class app\code\local\Company\Web\Helper\Data.php
and
Step 6: Now write the following file- app\code\local\Company\Web\Block\Adminhtml\Web.php
because i want to know about its necessity
Thanks
Hi Arvind,
ReplyDeleteThanks for your help.
Now, module is working according to requirements in admin as well as on frontend.
Hi Arvind,
ReplyDeleteGreat tutorial, only forgot one step. The creation of app/code/local/Company/Web/Model/Status.php. For everyone's convenience, here is the code from the download:
< ?php
class Company_Web_Model_Status extends Varien_Object
{
const STATUS_ENABLED = 1;
const STATUS_DISABLED = 2;
static public function getOptionArray()
{
return array(
self::STATUS_ENABLED => Mage::helper('web')->__('Enabled'),
self::STATUS_DISABLED => Mage::helper('web')->__('Disabled')
);
}
}
Thank you very much. It works perfectly :)
ReplyDeleteThis is surely a lot of stuff without any explanation...can you please explain a little what is the code doing at each step...thanks
ReplyDeleteError : Fatal error: Call to a member function setData() on a non-object in C:\wamp\www\magento\app\code\core\Mage\Adminhtml\Block\Widget\Form\Container.php on line 129
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThank you for this excellent tutorial.
ReplyDeleteI would like to comment on one detail, though.
Your class Company_Web_Adminhtml_WebController derives from Mage_Adminhtml_Controller_action.
According to my experiences, this should derive from Mage_Adminhtml_Controller_Action (notice the uppercase A in the end), or else it will stop working once you enable the Magento compiler.
Kind regards
Thanks for the notice :)
Deletenice one..
ReplyDelete@Arvind,
ReplyDeleteHow can we allow the user( having limited roles ) to access the module?
Thanks
Mahak