Questions tagged [overrides]

Questions about overriding core features (class rewrites, local code pool, theme overrides). For URL rewrites, use the "url-rewrite" tag instead.

Filter by
Sorted by
Tagged with
8
votes
2answers
3k views

Are we forced to rewrite a template in Magento2 when rewritting a block?

This question is about following Magento2 best practices. I had to rewrite \Magento\Theme\Block\Html\Topmenu::_addSubMenu() method in order to add some wrappers around elements. Now, because it's a ...
8
votes
2answers
2k views

Circular dependency: Magento\Customer\Model\Session depends on Company\Modulename\Plugin\Config\Share and vice versa

How to override or Use plugin for isWebsiteScope() function from Magento\Customer\Model\Config\Share.php file, I have used plugin for below function but I want to get current customer session in ...
7
votes
5answers
1k views

Magento 1: model rewrite vs event dispatching, best strategy?

I'm working on a module where I need to modify the behavior of the getTracking() method in a shipping method carrier model. For example let's take this default one: ...
7
votes
2answers
629 views

Strategy for rewriting classes

[TL:DR] I have Core_Class_A and Core_Class_B extends Core_Class_A. I need to rewrite both of them and add a common functionality. So I made this: Custom_Class_A extends Core_Class_A. The question ...
7
votes
6answers
8k views

How to override final_price.phtml in magento 2?

I want to override final_price.phtml, I have tried following in my module but it is not working. I have created app/code/MyVendor/MyModule/view/frontend/layout/catalog_product_prices.xml <layout ...
7
votes
2answers
8k views

How to override observers in Magento 2?

I was trying to override execute function of Magento\CatalogUrlRewrite\Observer\ProductProcessUrlRewriteSavingObserver using preference in di.xml <preference for="Magento\CatalogUrlRewrite\...
7
votes
3answers
4k views

Magento 2 add extra button in backend

I'd like to add another button in the backend on the cms page edit view. So I've created a module (with the help of: https://community.magento.com/t5/Programming-Questions/Overriding-a-block-in-...
7
votes
2answers
8k views

Overriding a core controller's preDispatch method

I need to override a core controller's preDispatch method. The core controller inherits from Mage_Checkout_Controller_Action, which itself has a preDispatch method that needs to be called. Since I'm ...
7
votes
5answers
2k views

Changing breadcrumbs separator symbol

By default the breadcrumbs look like: homepage > category > product. I would like to change the greater than (>) symbol. The code that generates it is in vendor/magento/magento2-base/lib/web/css/...
7
votes
2answers
12k views

Magento 2 How to override Protected Function

I want to override a block function in _createWishlistItemCollection located in folder /vendor/magento/module-wishlist/Block/AbstractBlock.php I have used the plugin method to override the block ...
7
votes
1answer
5k views

Struggling with Observer rewrite (not conflicts that I can find)

I am trying to rewrite an observer in the extensions Xtento_GridActions. The observer is established this way: <core_block_abstract_prepare_layout_after> <observers> ...
7
votes
3answers
2k views

What is the correct way to override / replace the custom options container?

Background I am developing a module that creates a few custom entities which relate/impact the options available for a particular product. Here's how it works: When a product loads, a query is ...
7
votes
2answers
2k views

AccountController override not working on new Action and doing 302 redirection

I am try add new action on AccountController Now: AccountController is override properly But it is whenever hit new Action (ajaxLoginPostAction) is redirect to 302. I add ajaxLoginPost() as open ...
7
votes
1answer
298 views

Magento 2.3.1 override view.xsd Using Plugin Not working before 2.3.1 it's Working

I am trying to override view.xsd using Plugin and it's working on magento 2.1.x and 2.2.x but not working in 2.3.1. I Add Same code To describe Here. Extending the complexType named "imageType&...
7
votes
2answers
3k views

How do I reference a block that only has an alias, and no name in Magento 2?

I am attempting to modify some arguments for a block that is defined in module-sales/view/adminhtml/layout/sales_order_view.xml on line 41. <block class="Magento\Sales\Block\Adminhtml\Order\View\...
7
votes
1answer
898 views

Override same Model/Controller in 2 different modules

How to override same class which exist in 2 different custom modules Eg: 1) I have a file Result.php. from Vendor\Module1\Block\Result and almost same Result.php from Vendor\Module2\Block\Result which ...
6
votes
3answers
11k views

How to override an admin theme template?

I would like to override app/design/adminhtml/default/default/template/page.phtml i'm currently using an extension that overrides app/design/adminhtml/default/default/template/page/header.phtml with ...
6
votes
3answers
3k views

How to override a Zend class?

I want to override a Zend class (Zend_Date). In Magento 1, I used to put Date.php in app/code/community/Zend and Magento itself used to do the rest. But now, there is no such directory. How can I ...
6
votes
1answer
4k views

How to override adminhtml phtml in magento 2?

Does anyone know how to override the below template? vendor\magento\module-backend\view\adminhtml\templates\media\uploader.phtml.
6
votes
2answers
1k views

How to exclude products being added to cart based on products attributes?

How can i set a condition, if pre-ordered products are purchased, no other products can be added to cart? How can I set a condition like, if some of the "non-pre-order" products is in the cart, ...
6
votes
3answers
4k views

Magento 2: How to override newsletter Subscriber model

I want to add 3 new fields in news letter popup for that i have written custom module. i am overriding Subscriber model and New Action Controller. But not able to call subscribe method of subscriber ...
6
votes
1answer
2k views

Magento2 Override Contact Post Controller [duplicate]

how to Override contact controller in custom module? venoder/magento/module-contact/Controller/Index.php
6
votes
1answer
5k views

Magento 2: Overriding Block class – not generating output

I'm trying to override the module-catalog/Block/Product/View/Options/Type/Select.php class with a new version which includes a few other bits of custom php (adding HTML classes and IDs to the ...
6
votes
2answers
6k views

How to override core class which is already overrided by other custom module in Magento 2

How to override core class which is already overrided by other custom module I have module1 and module2 overriding CatalogSearch module. in Module1 etc/di <preference for="Magento\CatalogSearch\...
6
votes
3answers
2k views

How to override crontab.xml?

I need to override a crontab.xml from: vendor/magento/module-integration/etc/crontab.xml <job name="expired_tokens_cleanup" instance="Magento\Integration\Cron\CleanExpiredTokens" method="...
6
votes
1answer
3k views

Magento 2: override block class by product type

Sorry but I dont know how to define my quetion.Let me show you code : Magento 1 : <checkout_cart_index> <reference name="checkout.cart"> <action method="addItemRender">...
6
votes
1answer
3k views

Why can't Simple Products with options be grouped?

Synopsis I have a store where-by I create a Grouped Product and associate a number of Simple Products. When I add custom options to the simple products it is not visible in the Grouped Products' ...
6
votes
2answers
267 views

Magento 2: EQP Error Possible useless method

I'm doing EQP of custom module then its shows error as below: Possible useless method overriding detected You can check this screenshot error is on line no. 20 Let me know if anyone has a ...
6
votes
1answer
266 views

How to override Interface of Other custom module?

I have tried with preference to override interface as below in di.xml file <preference for="Custom\Module\Api\Data\AccountInterface" type="Override\Module\Api\Data\AccountInterface" /> <...
6
votes
1answer
971 views

Override Wishlist view.phtml from custom module not working

I tried to override wishlist view.phtml which loaded at customer account page like this: app/code/Test/Salesman/view/frontend/layout/wishlist_index_index.xml <?xml version="1.0"?> <page ...
6
votes
0answers
665 views

How to override class Virtual Type class

I saw this, but it don't work for me. How to override Virtual Type class in Magento 2 <virtualType name="categoryFilterList" type="Magento\Catalog\Model\Layer\FilterList"> <arguments>...
5
votes
3answers
12k views

Trying to override a controller

I am trying to override a Mage controller which is in Mage/Catalog/controllers/CategoryController.php. The folder structure which I created in trying to override the above controller is as follows: -...
5
votes
4answers
2k views

Magento 2: Add a Custom Import Sample File to vendor/magento/module-import-export/Files/Sample directoy

I created a custom import module from two custom models and tables. The imports works fine, and without any error or problem now. But I noticed that next to Entity Type dropdown, appears a "Dowload ...
5
votes
3answers
666 views

Where should i put my function if i need it only in one Template?

I got a template called dashboard.phtml and i want to add a function there. I thought it was a bad practice to write it directly in the template it self so where should i put it? The class for this ...
5
votes
3answers
4k views

Magento 2 - How do I programmatically remove payment method?

I've followed the guide on the selected answer here: Payment method only admin Magento 2? But still no luck. What I want is to be able to show the Cash On Delivery method only to certain customers. ...
5
votes
3answers
1k views

How to override Session by using a module?

I'm using magento 1.4.1.1. I'm looking for a way to make a new module override "/var/www/app/code/core/Mage/Customer/Model/Session.php". I know how overriding controllers, but models. My files are as ...
5
votes
2answers
4k views

Magento 2.0.x Remove Account Tab in Mobile Menu

Summary: I'd like to remove the entire Account tab from the Magento 2.0.x mobile menu. Our site doesn't have accounts for users, it's more like a catalog with no purchasing. I've found many examples ...
5
votes
3answers
3k views

How to override customerData folder's file in magento 2?

I want to override app/code/Magento/Checkout/CustomerData/DefaultItem.php file. Becuase i have to change in this file. So how can i override this file
5
votes
2answers
504 views

How to get list of overridden controllers?

Is it possible to get list of all overridden controllers ? How do I get a list of all class rewrites? mainly applies for blocks, helpers and models.
5
votes
3answers
5k views

Magento override Adminhtml Customer Controller

I have been trying to override magento(1.9) admin's customer controller with my controller. But even though I have followed the steps correctly, I couldn't override the customer controller. Following ...
5
votes
2answers
2k views

Rewriting a model that has already been rewritten

I've read about ten different places (mostly answers on Magento stack exchange) about how to rewrite a model that has already been rewritten, but can't get my module to work. I've used the "Modules ...
5
votes
1answer
8k views

Magento 2: How to override UI component XML grid?

I need to override sales_order_grid.xml from ui_component of Magento_Sales. I want to remove some part of it but I don't know how to override it, I know how to override phtml from the custom module ...
5
votes
1answer
2k views

How to Override phtml file in Magento 2?

I am overwriting vendor/magento/module-catalog/view/frontend/templates/product/view/attributes.phtl and I tried puting the overriden file in two locations but no chages occur First: app/code/<...
5
votes
1answer
6k views

How to Override Mage_Checkout_Block_Links

What is the proper way to override a method, for example, the Mage_Checkout_Block_Links::addCartLink() method. My goal is to add some HTML before the Mage_Checkout_Block_Links::addCartLink() method. ...
5
votes
2answers
6k views

How to Override Module CSS in Custom Theme?

I am using Magento 2.1.3 EE and my custom theme is using Luma as it's parent. I am trying to override a third-party module's CSS in my custom theme. I am not using LESS. When I say override, I mean ...
5
votes
1answer
361 views

Magento 1: adminhtml controller rewrite and module dependencies

Explanation So I have a module, I'll call it Hello_World with the following code in config.xml <admin> <routers> <adminhtml> <args> &...
5
votes
3answers
654 views

Magento 2: How to Override core file [closed]

I want to override this core file vendor/magento/module-tax/Model/Sales/Total/Quote I have already followed the standard Magento2 approaches to override core file but unable to fetch tax ...
5
votes
1answer
1k views

Override the customer account creation email template in magento2

How can I override the core email template of customer account creation in magento2 please give solution
5
votes
1answer
763 views

How can I override server-side form validation?

I want to provide additional server-side validation of the address forms in Magento, both in Checkout and Customer. I can override Mage_Checkout_OnepageController, ...
5
votes
2answers
138 views

Magento 2 : How to override files from Magento core framework?

Actually I'm refering to #19247 for PHP 7.2 specific issue. that partially solved my issue but can't able to override that file. I tried using preference here's what I tried. <preference for="...

1
2
3 4 5
25