Magento-How can i override admin module correctly - magento

Hi friends:
I have overrided some modules : "Enterprise/Pci/Model/Observer.php","Mage/Admin/Model/User.php","Mage/Admin/Model/Session.php","Mage/Admin/Model/Observer.php".
And configuration as follows(config.xml):
`<global>
<models>
<Pci>
<rewrite>
<observer>App_Pci_Model_Observer</observer>
</rewrite>
</Pci>
</models>
</global>`
....
`<global>
<models>
<Admin>
<rewrite>
<observer>App_Admin_Model_Observer</observer>
<session>App_Admin_Model_Session</session>
<user>App_Admin_Model_User</user>
</rewrite>
</Admin>
</models>
</global>`
but it doesn't work, my code is not run.
Any help is greatly appreciated.

The module names are case-sensitive. Instead of <Admin> use <admin>. Instead of <Pci> use <enterprise_pci>.

Related

overwriting resource model class in magento

I am overwriting Mage_Catalog_Model_Resource_Product_Collection class to Namespace_Catalog_Model_Resource_Product_Collection to overwrite a protected function(_preparePriceExpressionParameters).
this is code I wrote in config.xml to overwrite this class file.
<models>
<catalog>
<rewrite>
<resource_product_collection>Namespace_Catalog_Model_Resource_Product_Collection</resource_product_collection>
</rewrite>
</catalog>
</models>
but it does not work, then I changed the code as below but this also does not work.
<models>
<catalog_resource_product>
<rewrite>
<collection>Namespace_Catalog_Model_Resource_Product_Collection</collection>
</rewrite>
</catalog_resource_product>
</models>
can any one have the idea what I made wrong.
the node above the rewrite has to match the <resourceModel> from the model you want to overwrite, so:
<global>
<models>
<namespace_catalog>
<class>Namespace_Catalog_Model</class>
</namespace_catalog>
<catalog_resource>
<rewrite>
<product_collection>Namespace_Catalog_Model_Resource_Product_Collection</product_collection>
</rewrite>
</catalog_resource>
</models>
</global>
The last one should be fine. Maybe another module is already overwriting Mage_Catalog_Model_Resource_Product_Collection which conflicts with your overwrite.

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 Overwrite admin template phtml with one from my module

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

How can override Mage_Catalog_Model_Category_Attribute_Source_Mode in MAGENTO?

How can override ATTRIBUTE SOURCE in CMS Magento ?
Tried standard method but not working.
I think that this unreal :(
In the config.xml file:
<models>
<catalog>
<rewrite>
<category_attribute_source_mode>YOUR CLASS HERE</category_attribute_source_mode>
</rewrite>
</catalog>
</models>

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