Magento : Create admin module - magento

I have a problem. I following guideline but it doesn't work. I don't know debug how. Please tell me the way resolve problem.
This is HS_Imagepro.xml in etc/modules/ folder
<?xml version="1.0"?>
<config>
<modules>
<HS_Imagepro>
<active>True</active>
<codePool>core</codePool>
</HS_Imagepro>
</modules>
</config>
This is config.xml in HS/Imagepro/etc folder
<?xml version="1.0"?>
<config>
<modules>
<HS_Imagepro>
<version>0.1.1</version>
</HS_Imagepro>
</modules>
<admin>
<routers>
<adminhtml>
<use>admin</use>
<args>
<modules>
<module>HS_Imagepro</module>
<frontName>imagepro</frontName>
</modules>
</args>
</adminhtml>
</routers>
</admin>
<adminhtml>
<menu>
<imagepro_menu translate="title" module="imagepro">
<title>ImagePro</title>
<sort_order>9999</sort_order>
<children>
<first_page module="imagepro">
<title>Our First Page</title>
<action>imagepro/index/index</action>
</first_page>
</children>
</imagepro_menu>
</menu>
</adminhtml>
<global>
<helpers>
<imagepro>
<class>HS_Imagepro_Helper</class>
</imagepro>
</helpers>
</global>
</config>
This is IndexController.php in HS/Imagepro/controllers/
<?php
class HS_Imagepro_IndexController extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
?>
The result is the page not found.
If The following right guideline, access link http://localhost/magento/index.php/imagepro/ will appear admin login screen.

In ,HS_Imagepro.xml file the test TRUE Should be true.
routing code Wrong in config.xml
<?xml version="1.0"?>
<config>
<modules>
<HS_Imagepro>
<version>0.1.1</version>
</HS_Imagepro>
</modules>
<admin>
<routers>
<!-- Includes our controller, so when we add the adminhtml menu item below, it is found! -->
<adminhtml>
<args>
<modules>
<imagepro before="Mage_Adminhtml">HS_Imagepro_Adminhtml</imagepro>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
Also controller file and path name is wrong
HS/Imagepro/controllers/Adminhtml/ImageproController.php
<?php
class HS_Imagepro_Adminhtml_ImageproController extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
?>
Testing url yourhost/magento/index.php/admin/imagepro
More details on http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/custom_module_with_custom_database_table#directory_additions
and frontend module http://www.amitbera.com/create-an-magento-extension-with-custom-database-table/

Related

Magento 1.9 - Creating a new page not working

I'm trying to create a new page to my module without success. I have created a module with the contents:
app\code\local\CompanyName\Insignias\etc\config.xml
<config>
<modules>
<CompanyName_Insignias>
<version>0.0.1</version>
</CompanyName_Insignias>
</modules>
<frontend>
<routers>
<insignias>
<use>standard</use>
<args>
<module>CompanyName_Insignias</module>
<frontName>insignias</frontName>
</args>
</insignias>
</routers>
<layout>
<updates>
<insignias>
<file>insignias.xml</file>
</insignias>
</updates>
</layout>
</frontend>
<...>
</config>
app\code\local\CompanyName\Insignias\controllers\IndexController.php
<?php
class CompanyName_Insignias_IndexController extends Mage_Core_Controller_Front_Action {
public function indexAction() {
$this->loadLayout();
$this->renderLayout();
}
}
and
app/design/frontend/base/default/layout/insignias.xml
<?xml version="1.0"?>
<layout>
<insignias_index_index>
<reference name="content">
<block type="insignias/index" name="insignias_index" template="insignias/index.phtml" />
</reference>
</insignias_index_index>
</layout>
I have created the index.phtml file at app/design/frontend/base/default/template/insignias/index.phtml with a <?php echo "worked" ?> to test it, but when I try to access domain/index.php/insignias it shows me all the default magento blocks and a blank page in the middle where my echo should appear.
Can someone help me?
edit:
Here is a picture of my screen
There's anything in the log files?
--
Btw...
You need to call your block in the indexController.php before renderLayout()
The call would look something like
$myBlock = $this->getLayout()->createBlock('Mage_Core_Block_Template', 'newpage', array('template' => 'newpage/content.phtml'));
$this->getLayout()->getBlock('content')->append($myBlock);
--
You can find Magento log in /var/log within your root Magento installation
There will usually be two files by default, exception.log and system.log.
app/design/frontend/base/default/template/checkout/onepage/shipping_method/available.phtml
app/etc/modules/AMA_Checkout.xml
<?xml version="1.0"?>
<config>
<modules>
<AMA_Checkout>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Checkout />
</depends>
</AMA_Checkout>
</modules>
</config>
app/code/local/AMA/Checkout/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<AMA_Checkout>
<version>1.0.0</version>
</AMA_Checkout>
</modules>
<global>
<blocks>
<amacheckout>
<class>AMA_Checkout_Block</class>
</amacheckout>
</blocks>
</global>
</config>
app/code/local/AMA/Checkout/Block/Onepage/Shipping/Method/Available.php
<?php
class AMA_Checkout_Block_Onepage_Shipping_Method_Available extends Mage_Checkout_Block_Onepage_Shipping_Method_Available
{
public function _construct()
{
parent::_construct();
$this->setTemplate('amacheckout/checkout/onepage/shipping_method/available.phtml');
}
}
template:
app/design/frontend/default/base/template/amacheckout/checkout/onepage/shipping_method/available.phtml

not load controller in magento, why?

config.xml
<?xml version="1.0"?>
<config>
<modules>
<Asgard_New>
<version>1.6.0.0</version>
</Asgard_New>
</modules>
<global>
<models>
<asgardnew>
<class>Asgard_New_Model</class>
</asgardnew>
</models>
<helpers>
<asgardnew>
<class>Asgard_New_Helper</class>
</asgardnew>
</helpers>
</global>
<frontend>
<routers>
<asgardnew>
<use>standard</use>
<args>
<module>Asgard_New</module>
<frontName>new</frontName>
</args>
</asgardnew>
</routers>
</frontend>
</config>
Asgard_New.xml
<?xml version="1.0"?>
<config>
<modules>
<Asgard_New>
<active>true</active>
<codePool>local</codePool>
</Asgard_New>
</modules>
</config>
IndexController.php
<?php
class Asgard_New_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
echo "Hello, magento!!";
}
public function helloAction()
{
echo "Hello, action!!";
}
public function layoutAction()
{
$xml = $this->loadLayout()->getLayout()->getUpdate()->asString();
$this->getResponse()->setHeader("Content-Type", "text/plain")->setBody($xml);
Mage::log($xml, Zend_Log::INFO, 'layout_log', true);
}
public function defaultAction()
{
$this->loadLayout()->renderLayout();
}
}
?>
Modul -> local/Asgard I have folders with same code Test ans New
http://magento/test/index/index
http://magento/new/index/index
Not work, last two days works, but today i try created a own package and theme this is stop working. Why its may happened, guys? Thanks!
Try to replace asgardnew with new
<frontend>
<routers>
<new>
<use>standard</use>
<args>
<module>Asgard_New</module>
<frontName>new</frontName>
</args>
</new>
</routers>
</frontend>

I want to know why my Magento Module with only controllers is not working

This is my activation file,
in app/etc/modules/My_Test.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<My_Test>
<active>true</active>
<codePool>local</codePool>
</My_Test>
</modules>
</config>
This is my config file in app/code/local/MY/Test/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<global>
<helpers>
<my_test>
<class>My_Test_Helper</class>
</my_test>
</helpers>
<models>
<mytest>
<class>My_Test_Model</class>
</my_test>
</models>
<blocks>
<my_test>
<class>My_Test_Block</class>
</my_test>
</blocks>
</global>
<frontend>
<routers>
<my_test>
<use>standard</use>
<args>
<module>My_Test</module>
<frontName>test</frontName>
</args>
</my_test>
</routers>
</frontend>
</config>
This is my controllers code
in app/core/local/My/Test/controllers/IndexController.php
<?php
class My_Test_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
echo "This is the Module MyTest";
}
}
Now when i am giving the url
176.58.99.99/herbal/index.php/test/index/index
176.58.99.99/herbal/index.php/test/
176.58.99.99/herbal/test/index/index
176.58.99.99/herbal/test/
Its showing 404 error
You say your controller is located in app/core/local/My/Test/controllers/IndexController.php while it should be placed as followed: app/code/local/My/Test/controllers/IndexController.php
I had the same problem, but in my case it was about file permissions. Make sure that your files and directories have the proper access permissions, if not, magento will never be able to read those files.

Magento - local cartcontroller is not working

I'm trying to overwrite the function couponPostAction in Magento, which is in the cartcontroller.
I created a new local Module Nf_Ajaxcoupon.
this is the config file
<?xml version="1.0"?>
<config>
<modules>
<Nf_Ajaxcoupon>
<version>0.1.0</version>
</Nf_Ajaxcoupon>
</modules>
<global>
<rewrite>
<Nf_Ajaxcoupon_checkout_cart>
<from><![CDATA[#^/checkout/cart/#]]></from>
<to>/Ajaxcoupon/checkout_cart/</to>
</Nf_Ajaxcoupon_checkout_cart>
</rewrite>
</global>
<frontend>
<routers>
<Nf_Ajaxcoupon>
<use>standard</use>
<args>
<module>Nf_Ajaxcoupon</module>
<frontName>Ajaxcoupon</frontName>
</args>
</Nf_Ajaxcoupon>
</routers>
</frontend>
</config>
This is my module activation:
<?xml version="1.0"?>
<config>
<modules>
<Nf_All>
<active>true</active>
<codePool>local</codePool>
</Nf_All>
</modules>
</config>
This is my CartController.php file:
<?php
require_once 'Mage/Checkout/controllers/CartController.php';
class Nf_Ajaxcoupon_Checkout_CartController extends Mage_Checkout_CartController
{
function couponPostAction()
{
var_dump($_POST);
die('local');
}
}
?>
I can't understand why its not calling the local controller, when I go to system->configuration->advanced I see it is enabled.
Any suggestions why its not working or ways to debug it?
Thanks
This is the proper way to override a controller in config inside frontend node
<routers>
<checkout>
<args>
<modules>
<Nf_Ajaxcoupon before="Mage_Checkout">Nf_Ajaxcoupon_Checkout</Nf_Ajaxcoupon>
</modules>
</args>
</checkout>
</routers>
also are you sure that your configure file would not need to be for Nf_Ajaxcoupon not to Nf_All
<?xml version="1.0"?>
<config>
<modules>
<Nf_Ajaxcoupon>
<active>true</active>
<codePool>local</codePool>
</Nf_Ajaxcoupon>
</modules>
</config>

Magento Module Admin Controller Returns 404 Error

I am creating simple reports module by following this tutorial.When i try to open
http://localhost/dev/admin/adminhtml/report_example/simple
i get 404 error.Any help would be appreciated.Here's what i did
app/etc/modules/Package_Custom.xml
<?xml version="1.0"?>
<config>
<modules>
<Package_Custom>
<active>true</active>
<codePool>local</codePool>
</Package_Custom>
</modules>
</config>
app/code/local/Package/Custom/controllers/Adminhtml/Report/ExampleController.php
<?php
class Package_Custom_Adminhtml_Report_ExampleController extends Mage_Adminhtml_Controller_Action
{
public function _initAction()
{
$this->loadLayout()->_addBreadcrumb(Mage::helper('custom')->__('Custom'),Mage::helper('custom')->__('Custom'));
return $this;
}
}
?>
app/code/local/Package/Custom/etc/adminhtml.xml
<?xml version="1.0"?>
<config>
<menu>
<custom translate="title" module="custom">
<title>Custom</title>
<sort_order>15</sort_order>
<children>
<simple translate="title" module="custom">
<title>Simple Report<</title>
<sort_order>1</sort_order>
<action>adminhtml/report_example/simple</action>
</simple>
</children>
</custom>
</menu>
app/code/local/Package/Custom/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Package_Custom>
<version>1.0.0</version>
</Package_Custom>
</modules>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<custom before="Mage_Adminhtml">Package_Custom_Adminhtml</custom>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
You have to configure acl section in the adminhtml.xml
http://www.ecomdev.org/2010/10/28/defining-acl-resources-custom-and-admin-menu-in-magento.html
Solved the problem.In config.xml
<title>Simple Report<</title>
Should be
<title>Simple Report</title>

Resources