Magento Overwrite admin template phtml with one from my module - magento

I've gotten quite used to overwriting magento's frontend layout files, so I thought it would be easy to overwrite a phtml template in the admin panel - but I've gotten nowhere in the last six hours. All tutorials I've found so far are concentrating on creating a controller, but I only need to overwrite two phtml files since I only want to change the dispaly of the ordered items a little.
Specifically I want to overwrite the default/template/sales/order/view/items.phtml, normally i'd just match that path in my design folder of my own module and call it a day.
I can overwrite the block php file in Mage/Adminhtml/Sales/Order/View/Items.php through my config.xml:
<config>
...
<global>
...
<blocks>
...
<adminhtml>
<rewrite>
<sales_order_view_items>MyCompany_MyModule_Block_Adminhtml_Sales_Order_View_Items</sales_order_view_items>
</rewrite>
</adminhtml>
</blocks>
...
</global>
...
</config>
How can I tell Magento to use my phtml file in design/adminhtml//default/sales/order/view/items.phtml ?
Shouldn't these lines in my config.xml work?
<config>
...
<adminhtml>
<layout>
<updates>
<my_module>
<file>order_list.xml</file>
</my_module>
</updates>
</layout>
</adminhtml>
...
</config>
Any help is really appreciated! I really hope I've just overlooked something...

What you could do is put your custom module before Mage_Adminhtml
<admin>
<routers>
<adminhtml>
<args>
<modules>
<My_Module before="Mage_Adminhtml">My_Module_Adminhtml</My_Module>
</modules>
</args>
</adminhtml>
</routers>
</admin>
Then copy to your order_list.xml
<adminhtml_sales_order_view>
....
</adminhtml_sales_order_view>
from /app/design/adminhtml/default/default/layout/sales.xml
In order_list.xml you could now replace the block type and template file (phtml) location

Related

Magento Extension causes 404 Error from the Admin Panel

We have a Magento Extension on our website, written by an ex-employee. This extension was written just for this one website, and I am struggling to find out what is going wrong with this extension. Contacting the ex-employee has proven to be (how should I put this), an ineffective method for solving this problem, so I was hoping someone here could help me out.
The extension works fine on the site, but when we click on the extension in the backend, on the Admin Panel, we get a "404 Not Found 1" error.
Is there anything I can do (like changing log file settings) to find out what file is missing and causing this 404?
QUICK UPDATE
After rolling back a load of patches we have noticed that this problem only occurs after patch 5994. Is there anything in patch 5994 that could be causing these problems?
The extension itself has the following files:
\app\code\local\muz\Worldman\controllers\
WorldmanController.php
\app\code\local\muz\Worldman\controllers\Adminhtml\
WorldmanController.php
\app\code\local\muz\Worldman\controllers\etc
config.xml
\app\code\local\muz\Worldman\controllers\Helper
Data.php
I can make changes to the class names in the \app\code\local\muz\Worldman\controllers\Adminhtml\WorldmanController.php and instead of getting a 404 error, I get an actual crash report, stating that Controller file was loaded but class does not exist.
Again, this extension works fine on the site itself. Its just clicking on the extension itself from the Admin Panel menu that causes the 404.
The extension is enabled. I have logged out and back in a hundred times. Indexes have been re-indexed. Caches have been cleared and turned off. Servers have been rebooted. But to no avail.
At this point any suggestions for debugging any Magento extensions would be very much appreciated.
If this helps, here is the config.xml file:
<?xml version="1.0"?>
<config>
<modules>
<muz_Worldman>
<version>1.0.0</version>
</muz_Worldman>
</modules>
<global>
<helpers>
<worldman>
<class>muz_Worldman_Helper</class>
</worldman>
</helpers>
</global>
<frontend>
<routers>
<worldman>
<use>standard</use>
<args>
<module>muz_Worldman</module>
<frontName>worldman</frontName>
</args>
</worldman>
</routers>
<layout>
<updates>
<worldman>
<file>worldman.xml</file>
</worldman>
</updates>
</layout>
</frontend>
<adminhtml>
<menu>
<cms>
<children>
<worldman_adminform translate="title" module="worldman">
<title>Worldman Manager</title>
<action>worldman/adminhtml_worldman</action>
</worldman_adminform>
</children>
</cms>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<cms>
<children>
<worldman_adminform>
<title>worldman Manager</title>
</worldman_adminform>
</children>
</cms>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<worldman>
<file>worldman.xml</file>
</worldman>
</updates>
</layout>
</adminhtml>
</config>
The ACL settings are not set right for the user, that's why you get a 404. Even with the ACL set correctly you might get this error if you do not flush the Magento config cache and log out and then back in again.
From a quick look at your config, it seems like the XML part of the ACL settings is alright, but you might need to check if the file \app\code\local\muz\Worldman\controllers\Adminhtml\WorldmanController.php has a method like this in it:
protected function _isAllowed()
{
return Mage::getSingleton('admin/session')->isAllowed('cms/worldman_adminform');
}
I had a bunch of modules that stopped working because of this missing method after one of Magento's latest patches.
Also, did you try with an admin account where you should automatically have full access?
--------EDIT-------
The patch you mentioned (5994) gave me similar problems with one of my modules. It used frontend routing for the adminhtml-controller, so what I had to do was to remove the XML between <frontend>...</frontend> and replace it with something like this:
<admin>
<routers>
<adminhtml>
<args>
<modules>
<muz_Worldman after="Mage_Adminhtml">muz_Worldman_Adminhtml</muz_Worldman>
</modules>
</args>
</adminhtml>
<worldman>
<use>admin</use>
<args>
<module>muz_Worldman</module>
<frontName>worldman</frontName>
</args>
</worldman>
</routers>
</admin>
and also make sure that the the XML for ACL action - <action>worldman/adminhtml_worldman</action> is right, I had to make some changes to the URL so mine became more like (for you) adminhtml/worldman_adminform.

Magento extend cms block class

I'm trying to extend the magento class Mage_Cms_Block_Block. I've got my module active. I think the reason why its failing is to do with the config.xml.
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<VisibleBlocks_ShowBlocks>
<!-- The version of our module, starting at 0.0.1 -->
<version>0.0.1</version>
</VisibleBlocks_ShowBlocks>
</modules>
<global>
<blocks>
<mage_cms>
<rewrite>
<cms_blocks>VisibleBlocks_ShowBlocks_Block_Border</cms_blocks>
</rewrite>
</mage_cms>
</blocks>
</global>
</config>
Can someone explain to me what the tags inside the global tags mean? Can the tags inside rewrite be called anything?
OK seems that asking the questions made it clearer to me. Hope this hasn't a waste of time for anyone. 'mage_cms' should be 'cms' as that is the module i'm extending and 'cms_blocks' should be 'block'.
i have explain the details,please check
<global>
<blocks>
<cms><!--module name of rewrite class mage_cms -->
<rewrite>
<!-- file path of Block of app/code/core/mage/cms/block.php -->
<blocks>VisibleBlocks_ShowBlocks_Block_Border</blocks>
</rewrite>
</cms>
</blocks>
</global>
<config>
<global>
<blocks>
<cms>
<rewrite>
<block>VisibleBlocks_ShowBlocks_Block_Cms_Block</block>
</rewrite>
</cms>
</blocks>
</global>
</config>
With these tags, we say we will configure a block of Magento’s core called cms and we will rewrite () the « block » block of this module
Also make sure your module is active & being displayed in system/config/Advanced

Magento Change Tab Order in Edit Product Section

I want to change order of tabs in edit product section.For example,categories and inventory tab must be swapped.Overriding Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs block doesn't seem to work.
config.xml
<config>
<global>
<blocks>
<my_module>
<class>Company_Adminhtml_Block</class>
</my_module>
<adminhtml>
<rewrite>
<catalog_product_edit_tabs>Company_Adminhtml_Block_Catalog_Product_Edit_Tabs</catalog_product_edit_tabs>
</rewrite>
</adminhtml>
</blocks>
<global>
</config>
I copied Company_Adminhtml_Block_Catalog_Product_Edit_Tabs into local folder and swapped the category and inventory addTab code.Any pointers?
Make sure you have configured your module correctly. To do this, you can simply call from a controller action.
echo get_class(Mage::getBlockSingleton('adminhtml/catalog_product_edit_tabs'));
It should return Company_Adminhtml_Block_Catalog_Product_Edit_Tabs if you configuration is correct, or Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs if your configuration is failed.
Had the same issue. Flushing the cache helped.

Magento controller override

I am trying to overwrite a controller of an extension....that is overwriting the cart controller.
The extension currently overwriting the cart controller is:
Innoexts/Warehouse/controllers/Checkout/CartController.php
The config entry in the Innoexts module doing this is:
<frontend>
<routers>
<checkout>
<args>
<modules>
<Innoexts_Warehouse before="Mage_Checkout">Innoexts_Warehouse_Checkout</Innoexts_Warehouse>
</modules>
</args>
</checkout>
</routers>
...blah...blah...
</frontend>
The top of the innoext cartcontroller file is:
require_once 'Mage/Checkout/controllers/CartController.php';
class Innoexts_Warehouse_Checkout_CartController extends Mage_Checkout_CartController {
I want to overwrite it with this controller:
Myco/Warehousemod/controllers/Checkout/CartController.php
The top of the controller file is:
require_once 'Innoexts/Warehouse/controllers/Checkout/CartController.php';
class Myco_Warehousemod_Checkout_CartController extends Innoexts_Warehouse_Checkout_CartController {
The config entry ive created is:
<global>
...blah...blah...
<rewrite>
<myco_warehousemod_checkout_cart>
<from><![CDATA[#^/checkout/cart/#]]></from>
<to>/warehousemod/checkout_cart/</to>
</myco_warehousemod_checkout_cart>
</rewrite>
</global>
<frontend>
<routers>
<checkout>
<args>
<modules>
<Myco_Warehousemod before="Innoexts_Warehouse_Checkout">Myco_Warehousemod_Checkout</Myco_Warehousemod>
</modules>
</args>
</checkout>
</routers>
...blah...blah...
</frontend>
I am getting a 404 not found error for the checkout/cart URL now....Can anyone see where im going wrong? Online resources are very different...and confusing!! The issue may be with me trying to overwrite an overwriting controller...??
thanks in advance...
Need to remove the first rewrite:
<rewrite>
<myco_warehousemod_checkout_cart>
<from><![CDATA[#^/checkout/cart/#]]></from>
<to>/warehousemod/checkout_cart/</to>
</myco_warehousemod_checkout_cart>
</rewrite>
I think certain people should stop writing tutorials....cluttering up the web with their half-assed SEO efforts....
This part was used in the old versions of Magento (i think before 1.4), but if you want to extend a controller that has a rewrite like this in the config file, you have to do the same in your config.
<rewrite>
<myco_warehousemod_checkout_cart>
<from><![CDATA[#^/checkout/cart/#]]></from>
<to>/warehousemod/checkout_cart/</to>
</myco_warehousemod_checkout_cart>
</rewrite>
The new versions use only the part with before so you should have something like this:
<routers>
<checkout>
<args>
<modules>
<Myco_Warehousemod before="Innoexts_Warehouse">Myco_Warehousemod_Checkout</Myco_Warehousemod><!-- just the name of the module Innoexts_Warehouse the overridden folder will be taken from the part after the name of your module so Magento will look in app/local/Myco/Warehousemod/controllers/Checkout/* and load all the controllers from there -->
</modules>
</args>
</checkout>
</routers>
Just an additional notes for those who wants to know about confliction between extensions and possible solutions(just like above case), refer to the following links:
http://www.webshopapps.com/blog/2010/11/resolving-magento-extension-conflicts/
http://sweettoothrewards.com/wiki/index.php/Resolving_extension_conflicts
http://magebase.com/magento-tutorials/magento-extension-clashes-winners-and-loosers/
http://www.magestore.com/blog/2011/12/21/magento-methods-to-resolve-the-module-conflicts-in-magento/
This is a little notification on the include path of the controller.
This include path can cause errors if the Magento Compiler mode is turned on.
require_once 'Mage/Checkout/controllers/CartController.php';
Instead of that it is good to use
require_once Mage::getModuleDir('controllers', 'Mage_Checkout').DS.'CartController.php';
It will be safer.

Magento: How to override admin controller outside of adminhtml?

Simply put, I want to override ProcessController which is in the Mage/Index/controllers/Admninhtml/ProcessController.php.
I know how to override the front-end controller, but this gives me a headache for hours now. I can't put it to work. Here's my config file
<?xml version="1.0"?>
<config>
<global>
<models>
<twobuy_index>
<class>Twobuy_Index_Model</class>
</twobuy_index>
</models>
</global>
<admin>
<routers>
<index>
<args>
<modules>
<Twobuy before="Mage_Index">Twobuy_Index</Twobuy>
</modules>
</args>
</index>
</routers>
</admin>
</config>
And the controller declaration
include_once('Mage/Index/controllers/Adminhtml/ProcessController.php');
class Twobuy_Index_Adminhtml_ProcessController extends Mage_Index_Adminhtml_ProcessController
{
I tried overriding reindexAction, but my method never gets called.
Replace <index> with <adminhtml> in your config file. It might just be a copy-paste error but your <Twobuy> tag is incorrectly ended with </Ucon>.
<Twobuy before="Mage_Index">Twobuy_Index</Ucon>
Looks like an error in your XML
<twobuy_index before="Mage_Index">Twobuy_Index</twobuy_index>

Resources