overwriting resource model class in magento - 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.

Related

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 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 can i override admin module correctly

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>.

Resources