I have a Magento extension with custom product type that in config.xml use this action:
<routers>
<catalog>
<rewrite>
<product>
<to>custom-product-module/index</to>
<override_actions>true</override_actions>
<actions>
<view>
<to>custom-product-module/index/view</to>
</view>
</actions>
</product>
</rewrite>
</catalog>
</routers>
The problem is that this rewrite action affect also all the other product types like simple product, virtual product etc. What I want is to bring Magento to use this rewrite action only for the custom product type used from my extension.
Any help please? best regards
Related
I'm trying to modify the app/code/core/Mage/Adminhtml/Block/Customer/Grid.php file with my own grid, which is located at app/code/local/MyCompany/MyModule/Block/Adminhtml/Customer/Grid.php
I tried to add this code in my config.xml :
<blocks>
<adminhtml>
<rewrite>
<customer_grid>MyCompany_MyModule_Block_Adminhtml_Customer_Grid</customer_grid>
</rewrite>
</adminhtml>
</blocks>
but it didn't work, can somedboy help me?
[edit] I updated my code with the help of the first answer but this didn't work either, I've got a server error. My grid file works well if I replace my core file [/edit]
The config maps rewrites through the class group ("adminhtml" in this case):
<blocks>
<adminhtml>
<rewrite>
<customer_grid>Tegeso_Codepromo_Block_Adminhtml_Customer_Grid</customer_grid>
</rewrite>
</adminhtml>
</blocks>
See Mage_Core_Model_Config::getGroupedClassName() to see exactly how this works.
Hi I have some issues in overriding a magento core block. In my module I need to override Mage_Catalog_Block_Navigation
<blocks>
<catalog>
<rewrite>
<navigation>Mycompany_Mymodule_Catalog_Block_Navigation</navigation>
</rewrite>
</catalog>
</blocks>
but this is already overridden by another magento extension from another company:
<blocks>
<catalog>
<rewrite>
<navigation>Othercompany_Othermodule_Block_Navigation</navigation>
</rewrite>
</catalog>
</blocks>
Both extension overrides different methods and they don't know abut each other, but magento reads the second company overrides and not my. I don't want to use module dependencies. Is there any way to not break the two extensions functionality.
Yes, you have to decide which one officially overwrites the core Block. Have that one inherit the one that isn't doing the override, and have that one inherit the core one.
My_Custom_Block extends Other_Custom_Block
Other_Custom_Block extends Mage_Core_Block
Mage_Core_Block extends Whatever_Magento_Wants
Edit the config.xml files so that only My_Custom_Block is the one that is overriding the core Block.
EDIT
Here's the XML you need:
<blocks>
<catalog>
<rewrite>
<navigation>Mycompany_Mymodule_Catalog_Block_Navigation</navigation>
</rewrite>
</catalog>
</blocks>
Thx Max.
I think, like your example, that the "My_Custom_Block" should be the last hierarchic class, so you don't touch anythings in "Other_Custom_Block" class.
Then you have only to comment the rewrite rule in "Other Company" config.xml.
So I created a custom view.phtml file to display a different layout on the product page for event registration. I am able to display that custom view file if i add it to the XML field under the design tab.
What i want to do is create a custom product type in magento that already uses my new view-events.phtml. I know how to create the custom product type but how do I get the new product type to use my custom view file?
In your module's config.xml:
<config>
<global>
<catalog>
<product>
<type>
<!-- Change "custom" to your custom product type -->
<custom>
<!-- See app/code/core/Mage/Catalog/etc/config.xml for hints here -->
</custom>
</type>
</product>
</catalog>
</global>
<frontend>
<layout>
<updates>
<!-- Use your module's name here -->
<your_module>
<file>your_module.xml</file>
</your_module>
</updates>
</layout>
</frontend>
Then in the your_module.xml layout file just referenced:
<layout>
<PRODUCT_TYPE_custom>
<reference name="product.info">
<action method="setTemplate">
<template>path/to/your/view-events.phtml</template>
</action>
</reference>
</PRODUCT_TYPE_custom>
</layout>
I have run into a problem where shipping options are not making it to the PayPal Express review page. If the buyer enters a free shipping coupon and then uses PayPal Express, when they return from the PP website, the review page where the submit the order doesn't have the free shipping option.
I found a thread where this was answered by adding code to the Mage_Paypal_Model_Express_Checkout class. This change works, but modifying core code is a no-no, so I'm trying to rewrite the class and I'm having trouble. I've rewritten core classes before, but this one is different somehow and I can't figure it out. Can someone point me in the right direction?
here's the contents of my config.xml. Does this look right?
<config>
<modules>
<VPS_Paypal>
<version>0.1.0</version>
</VPS_Paypal>
</modules>
<global>
<models>
<paypal>
<rewrite>
<express_checkout>
<class>VPS_Paypal_Model_Express_Checkout</class>
</express_checkout>
</rewrite>
</paypal>
</models>
</global>
</config>
I haven't tested this, but based on the class name I would think that adding this to the section of your config would work:
<paypal>
<rewrite>
<express_checkout>Your_Model_Class_Here</express_checkout>
</rewrite>
</paypal>
Your custom class should extend Mage_Paypal_Model_Express_Checkout and only override the method you want to change.
I'm trying to change the way Magento shows options of an attribute with multiple select.
I have 10K options for this attribute.
How can I override the UI and use an Ajax based UI?
The admin will be able to filter options and present only ~20 each time.
I know how to use js and php for this but not in Magento.
Thanks
You can try to rewrite block class responsible for this attribute.
<global>
<blocks>
<adminhtml>
<rewrite>
<catalog_product_edit_tabs_price>Company_Module_Block_Adminhtml_Tabs_Price</catalog_product_edit_tabs_price>
</rewrite>
</adminhtml>
</blocks>
</global>
Then in your Company_Module_Block_Adminhtml_Tabs_Price you can re-declare function responsible for logic for price attribute (for example).
You should have a good knowledge of Magento for this.