Overriding adminhtml controller in Magento not working - magento

Sorry for my english.
Just a question. In my magento, when i refresh statistics in Reports / Resfresh statistics, it's okay but it redirects me on the homepage of my website.
I solved this problem by changing two lines code in app/code/core/Mage/adminhtml/controllers/Report/StatisticsController.php.
But it's better to create "an override".
So i decided to create a module in app/code/local/myname/.
I have my file in app/etc/modules myname_all.xml wich contains :
<?xml version="1.0"?>
<config>
<modules>
<MyName_AdminExtras>
<active>true</active>
<codePool>local</codePool>
</MyName_AdminExtras>
Next, I create app/code/local/Myname/AdminExtras/Adminhtml/etc/config.xml which contains
<?xml version="1.0"?>
<config>
<modules>
<MyName_AdminExtras>
<version>0.1.0</version>
</MyName_AdminExtras>
</modules>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<MyName_AdminExtras before="Mage_Adminhtml">MyName_AdminExtras_Adminhtml</MyName_AdminExtras>
</modules>
</args>
</adminhtml>
</routers>
</admin>
And finally, i created a folder named controllers which contains another folder named Report and the file named StatisticsController.php which is calling the base file /app/code/core/Mage/Adminhtml/controllers/Report/StatisticController.php
But it doesn't word. File is not calling by Magento.
What's wrong ?

Hum sorry i found the answer. My folders weren't ok.
I just follow this way :
App/code/local/MyName/AdminExtras/controllers/adminhtml..
instead of
App/code/local/MyName/AdminExtras/Adminhtml/controllers

Related

Magento 1 - module controller not working

Tyring to create a module where i can create a product dynamically using catalog->products model, and redirect control to the product's review page. Need only single controller with single action. No blocks, helpers, templates.... nothing required.
But it seems like controller action is not properly routed, there is some mistake in code or configuration ... getting 404 not found error
Trying this url:
http://localhost/magento_test/dynamicproduct/index/index
Namespace: Waqasalieee
Module name: Dynamicproduct
Magento version: 1.7.0.2
Here are the file contents:
local/Waqasalieee/Dynamicproduct/controllers/IndexController.php
<?php
class Waqasalieee_Dynamicproduct_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction() {
die('working in index');
}
}
?>
local/Waqasalieee/Dynamicproduct/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Waqasalieee_Dynamicproduct>
<version>1.0</version>
</Waqasalieee_Dynamicproduct>
</modules>
<frontend>
<routers>
<dynamicproduct>
<use>standard</use>
<args>
<module>Waqasalieee_Dynamicproduct</module>
<frontName>dynamicproduct</frontName>
</args>
</dynamicproduct>
</routers>
</frontend>
</config>
app/etc/modules/Waqasalieee_Dynamicproduct.xml
<?xml version='1.0'?>
<config>
<modules>
<Waqasalieee_Dynamicproduct>
<codepool>local</codepool>
<active>true</active>
</Waqasalieee_Dynamicproduct>
</modules>
</config>
It should show some error or 'working in index' (string) but its giving 404 not found error.
I was having the same sympton and landed here. For me the error was not a erroneous XML config but that the Store Code was actually added to the URL (that's a magento feature, not a bug) and so my controller was only accessible by adding a valid store code to the URL like http://mystore/<storecode>/<controller>/<action>.
In my case http://mage.localhost/en/customer/check
In your config.xml use codePool instead of codepool.
<?xml version='1.0'?>
<config>
<modules>
<Waqasalieee_Dynamicproduct>
<codePool>local</codePool>
<active>true</active>
</Waqasalieee_Dynamicproduct>
</modules>
</config>

Overriding Core Blocks

I'm try to overriding Mage_Core_Block_Messages
I'm create module
Mycompany_Core.xml and save in path app/etc/modules/Mycompany_Core.xml
<?xml version="1.0"?>
<config>
<modules>
<Mycompany_Core>
<active>true</active>
<codepool>local</codepool>
</Mycompany_Core>
</modules>
</config>
next I was create in app/code/local/Mycompany/Core/Block/Messages.php
class Mycompany_Core_Block_Messages extends Mage_Core_Block_Messages
{
//update method
}
and add config.xml in app/code/local/Mycompany/Core/etc/config.xml
<config>
<modules>
<Mycompany_Core>
<version>0.0.1</version>
</Mycompany_Core>
</modules>
<global>
<blocks>
<core>
<rewrite>
<messages>Softdk_Core_Block_Messages</messages>
</rewrite>
</core>
</blocks>
</global>
</config>
But i don't see any result on frontend, I'm wonder where I'm make mistake.
Thx for help.
There are two things that caught my eye.
1.) In your module's registration file, it should be codePool and not codepool (as also said by David in comments)
2.) What is Softdk? If that is the name of your new module, then replace Mycompany with Softdk everywhere in your module.
Clear cache and voila!

want to over-ride adminhtml in Magento [duplicate]

This question already has answers here:
Magento - Override adminhtml template file
(4 answers)
Closed 8 years ago.
I have set up a custom theme in Magento admin panel under "Design" tab
I can now put my custom code in
\app\design\frontend\default\MYTHEME\template
instead of
\app\design\frontend\base\default\template
I would like to do the same for the admin panel code. In other words, I would like to selectively replace vanilla code in this directory
\app\design\adminhtml\default\default\template
with custom code, likely in this directory
\app\design\adminhtml\default\MYTHEME\template
Magento does not seem to recognize this automatically.
edit - - -
For the sake of maintainability it would be beneficial to have a global over-ride like we have in 'frontend'. Over-riding module by module in the module layout may not be obvious to next person that looks at the code.
Try
In /app/code/local/MageIgniter/AdminThemeAndMod/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<MageIgniter_AdminThemeAndMod>
<version>0.1.0</version>
</MageIgniter_AdminThemeAndMod>
</modules>
<stores>
<admin>
<design>
<theme>
<default>mageigniter</default>
</theme>
</design>
</admin>
</stores>
</config>
In /app/etc/modules/MageIgniter_AdminThemeAndMod.xml
<!-- /app/etc/modules/MageIgniter_AdminThemeAndMod.xml -->
<config>
<modules>
<MageIgniter_AdminThemeAndMod>
<active>true</active>
<codePool>local</codePool>
</MageIgniter_AdminThemeAndMod>
</modules>
</config>
Then add your newly add/update files to
/app/design/adminhtml/default/mageigniter/layout/
/app/design/adminhtml/default/mageigniter/template/
/skin/adminhtml/default/mageigniter/
for "/app/etc/modules/MageIgniter_AdminThemeAndMod.xml", you mean -
<?xml version="1.0"?>
<!-- /app/etc/modules/MageIgniter_AdminThemeAndMod.xml -->
<config>
<modules>
<MageIgniter_AdminThemeAndMod>
<active>true</active>
<codePool>local</codePool>
</MageIgniter_AdminThemeAndMod>
</modules>
</config>

Magento costum module shows 404

I tried the tutorial on http://www.satollo.net/magento-pdf-invoices-customer-dashboard/comment-page-1#comment-47565.
This allows a user to view invoices as PDF on the frontend of my Magento store. The problem is, when I click on the link which points to Pdfinvoice/index/invoices/order_id/5/ it shows a 404 error.
I registered the module as followed:
(renamed to module to Pdfinvoice to avoid conflict with another module)
<?xml version="1.0"?>
<config>
<modules>
<Pdfinvoice>
<active>true</active>
<codePool>local</codePool>
</Pdfinvoice>
</modules>
</config>
app/etc/modules/Pdfinvoice.xml
I am breaking my head over this.
Maybe the module isn't registered? I've tried googling it, but I can't get it to work.
Does anyone know a solution to this problem?
When you rename the module in the module definition xml, make sure you do the same with your local folder (app/code/local/Pdfinvoice), your config.xml:
app/code/local/Pdfinvoice/etc/config.xml
<config>
<modules>
<Pdfinvoice>
<version>1.0.0</version>
</Pdfinvoice>
</modules>
<frontend>
<routers>
<pdf>
<use>standard</use>
<args>
<module>Pdfinvoice</module>
<frontName>pdfinvoice</frontName>
</args>
</pdf>
</routers>
</frontend>
.. and your new controller:
app/code/local/Pdfinvoice/controllers/IndexController.php
<?php
class Pdfinvoice_IndexController extends Mage_Core_Controller_Front_Action {
public function invoicesAction() {
...
Works flawless, I installed the module in minutes.

Change of Magento contacts page URL

How can I change Magento contacts page URL from /contacts to contact-us.html?
Thanks for any advice.
In the Catalog menu click on URL Rewrite Management.
Click the Add URL Rewrite button.
Choose to add a Custom type.
Enter "contacts" for ID Path and Target Path.
Enter "contact-us.html" for the Request Path.
Click the Save button.
The 'proper' way would be to create a small module similar to the below;
app/etc/modules/Organisation_Module.xml
<?xml version="1.0"?>
<config>
<modules>
<Organisation_Module>
<active>true</active>
<codePool>local</codePool>
</Organisation_Module>
</modules>
</config>
and...
app/code/local/Organisation/Module/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Organisation_Module>
<version>0.0.1</version>
</Organisation_Module>
</modules>
<frontend>
<routers>
<contacts>
<use>standard</use>
<args>
<module>Mage_Contacts</module>
<frontName>contact-us.html</frontName>
</args>
</contacts>
</routers>
</frontend>
</config>
Upload your files, clear your cache and you're good to go.
Specifically must be
New Url in ID Path and Target Path.
Old Url in Request Path
Have you tried changing the URL stub?

Resources