The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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
49
votes
8answers
37k views

How to Override Core Block, Model and controller in Magento2

I'm stuck in overriding core model Blocks and controllers in Magento2. Can any one help on this? Let's take list toolbar as example where I need to add a new sort option called sort by most popular. ...
42
votes
5answers
2k views

What do I do when an extension overwrites a class globally and I want to use the original?

We're using an extension which globally overwrites the Mage_Catalog_Block_Product_List_Toolbar block. <global> <blocks> <catalog> <rewrite> ...
34
votes
2answers
45k views

Extending / Overriding JS in Magento 2

As Magento2 is using RequireJS for loading scripts, and there's no more skin folder, I've stuck with a problem: How can I replace Magento's module JS file by my modified version? For example — the ...
23
votes
5answers
9k views

How do I get a list of all class rewrites?

Is there a way to list all rewrites and maybe other potential conflicts besides reviewing all configuration files? I have to analyse some projects with lots of extensions and custom modifications and ...
21
votes
4answers
2k views

Modern way of rewriting lib files

The problem is well known: lib classes are loaded exclusively through the autoloader, and we cannot change them other than: Copying them entirely to a codePool that is checked earlier than lib. ...
19
votes
4answers
13k views

How to override a HTML file using a custom module?

I'm developing a custom module for payment method in Magento 2. Currently, I'm using cc-form.html from vendor directory and module working fine. See below path: vendor/magento/module-payment/view/...
17
votes
2answers
2k views

Rewriting Magento 2 classes vs Plugins

Magento 2 has the concept of Plugins/Interception/Interceptors opposed to Magento 1. These act like a before|after the event for every public method. Which is nice. You can also use the around plugin ...
17
votes
3answers
13k views

Magento 2: rewrite controller

how can i rewrite a controller (that's actually an action) in Magento 2? I tried, as instructed here like this: I have my own module called Namespace_Module with a di.xml file, that is taken into ...
15
votes
3answers
12k views

How to rewrite a class that has already been rewritten?

Update: I found that the class I actually need to rewrite is SMDesign_SMDZoom_Block_Product_View_Media and not SMDesign_ColorswatchProductView_Block_Product_View_Media like I originally thought. ...
15
votes
1answer
15k views

How to override config.xml

I need to change contact us page email template type from "text" to "HTML". I found it is in the config.xml <email> <contacts_email_email_template translate="label" module="contacts">...
15
votes
5answers
11k views

Magento 2: How to set custom template for core block

I'm trying to override the register.phtml in my module, but it seems there are some config problem that make Magento unable to use my custom template to override the one in core module. I've checked ...
15
votes
3answers
2k views

Adding a new method to an Abstract Class in Magento 2

Like this thread said: Override abstract class in Magento 2 in Magento 1, I can just create a full new class. In Magento 2, we should use plugins instead, but plugins only allow me to modified ...
14
votes
2answers
6k views

How to override or disable core Plugins in Magento2?

I am building a marketplace using Magento2. For that reason I need to be able to load the order of the customer using the vendor's customer credentials. The problem with this is that Magento2 uses a ...
14
votes
1answer
469 views

Conditional RequireJs configuration (Load requirejs-config.js programmatically?)

I would like to replace a RequireJs component only on certain conditions (for example, based on configuration). Is there any way to programmatically prevent loading of my module's requirejs-config.js ...
13
votes
6answers
32k views

How to override .phtml files in Magento 2

I want to customize product details page, So it required to override some .phtml files in following locations. So I want to know, how to override .phtml files in vendor\magento\module-catalog\view\...
12
votes
7answers
9k views

Changing “Add to cart” button text in Magento 2.1.0 ( Overriding js file )

I have changed "Add to cart" text to "I want this" by overriding "vendor\magento\module-catalog\view\frontend\templates\product\list.phtml". But, when I click on "I want this" (i.e. "Add to cart" ) ...
12
votes
3answers
4k views

How to override Virtual Type class in Magento 2

How to override VirtualType block in Magento 2, I want to override following virtual type block with my own block, <virtualType name="Magento\CatalogSearch\Block\SearchResult\ListProduct" type="...
12
votes
4answers
10k views

Override abstract class in Magento 2

In Magento 1 I could copy abstract class to local or community directory and Magento used it, when autoload load this class. Is there some solution to make to Magento loads my class instead vendor/...
12
votes
1answer
16k views

How to override the controller AccountController

I need to override a method Controller Core/Mage/Customer/controllers/AccountController.php and add a new method. Since this controller to edit is wrong - it should be overridden. According to ...
12
votes
3answers
17k views

Rewrite controller magento

I need to overwrite action called _initAction from Controller: /app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php into my own module and controller: /app/code/local/...
11
votes
5answers
28k views

Mage::log() does not log in all files used by Magento?

I have overwritten Sitemap.php in app/code/local/Mage/Sitemap/Model/Sitemap.php. The file seems to be used, if I remove all contents, there's an error as expected. I copied the complete content of ...
11
votes
5answers
24k views

Magento 2: How to override mini-cart default template html file?

How to override /var/www/html/magento2/vendor/magento/module-checkout/view/frontend/web/template/minicart/content.html file in our custom theme?
11
votes
3answers
13k views

How do I override/rewrite a block class in Magento 1?

Note: This is intended as a canonical question that fully explains how block rewrites work and can be used as duplicate target for more specific "How do I override block X" or "Why does my rewrite not ...
11
votes
1answer
21k views

Magento 2 Override default header template

I have created my own theme by extending the Magento/Blank theme. Now want to override the default header template files link.phtml, topmenu.phtml, header.phtml which is located at vendor/module-...
11
votes
1answer
2k views

Override/remove XML Config node/value?

I want to remove some XML value without touching core XML files, is it possible ? The scenario is the following. In /app/code/core/Mage/Tax/etc/config.xml we have some config value for the totals (&...
11
votes
2answers
1k views

How can I add a page layout to Mage_Page module?

I discovered after upgrading Magento that the core Mage_Page's config.xml had been manually edited, and now I'm looking to change the XML in a way that doesn't overwrite core. Here is an example of ...
11
votes
1answer
452 views

How to override a static method in Magento2

Plugin Interceptors and overriding with preference does not work on static methods. Need to override getOptionArray method in Magento\Catalog\Model\Product\Visibility to return a custom visibility ...
10
votes
3answers
2k views

Magento 1 Class Rewrite in Magento 2 with Dependency Injection System

Poking around Magento 2's core code, it looks like the old class rewrite system has been ripped out and replaced with a new dependency injection system. Unfortunately, there's no documentation for ...
10
votes
2answers
18k views

How to overwrite core template files from a custom module?

I want to overwrite two files. Namely the view.phtml and print.phtml of sales orders. (path: app/design/frontend/base/default/template/sales/order/) I am creating a module in which I want to create a ...
10
votes
3answers
2k views

Magento 2 add new theme without changing core files. Grunt

How to extend default Magento 2 Grunt configuration without touching/editing core files like Gruntfile.js and dev/tools/grunt/configs/themes.js?
10
votes
1answer
832 views

Remove observer from third party extension

I have installed a blog module onto my Magento 2 platform. This blog module has an observer which automatically adds a new menu item into the primary navigation. I wish to stop this. The events.xml ...
10
votes
1answer
7k views

Where do you put modified WSDL files for the API to override the core definitions?

We've updated the standard WSDL definitions to support bundled product attributes for sku_type and price_type. I've tried putting the updated WSDL and WSI files in app/code/local/Mage/Catalog/etc/, ...
10
votes
2answers
695 views

How To Properly Disable a (Model) Rewrite

There is a third-party extension which rewrites a specific Magento core class. It should not matter if it is a block, helper or model, but in this case it is a model. Now I encounter that this rewrite ...
9
votes
1answer
4k views

override a zend library

i'm trying to override a zend library (Zend_Pdf_Page) and it doesn't seem to be working. i'm putting it in app/code/local/Zend/Zend_Pdf_Page.php, but the parent class is being used instead. are there ...
9
votes
2answers
13k views

Overriding Blank Theme Styles in Magento 2

How would you go about overriding the navigation styles for a custom theme when inheriting from the blank theme in Magento 2? I have a theme.css file in my app/design/frontend/<Vendor>/<...
9
votes
1answer
9k views

How to prevent module rewrite class conflict in Magento

I have a class rewrite problem in Magento Onepage Checkout as I have a custom module in the local code pool and a third party extension in the community code pool both extending the same class... I'...
9
votes
4answers
2k views

Magento 2 How to override vendor/magento/magento2-base/lib/web/css/source/lib/_navigation.less?

How Can I override vendor/magento/magento2-base/lib/web/css/source/lib/_navigation.less file in my custom theme ?
9
votes
2answers
508 views

Why use a theme when you have modules?

Inside of my custom module I have added the file Vendor/Theme/view/layout/default.xml which I am using to override a lot of the site's global templating with templates/blocks/layouts from the custom ...
9
votes
1answer
4k views

Magento 2 show normal price with special price on minicart

I can set Normal price along with Special price while put custom function in core file vendor/magento/module-weee/Block/Item/Price/Renderer.php public function getUnitItemPriceExclTax() { $...
9
votes
2answers
4k views

Magento 2: How to override gallery.css?

I want to override lib/web/mage/gallery/gallery.less and some module files in lib/web/mage/gallery/module/*.less I need to override them because I want to change the style of product gallery images....
9
votes
3answers
9k views

Magento 2: How to override Luma Theme Home Page

I'm using Magento 2 CE Version 2.1.0 on WAMP Windows 10 I already referred Magento 2: How to override mini-cart default template html file? Would like to override Magento 2 Default Luma Theme I ...
9
votes
1answer
1k views

Magento 2.1: how to remove argument and/or argument item from block?

I need to remove "from - to" price in bundle product page. So the question is how to remove item from argument? Block is created in magento2/vendor/magento/module-bundle/view/base/layout/...
9
votes
3answers
521 views

Overwrite js core function magento 2

I am trying to Overwrite some function from Magento_Swatches/js/SwatchRenderer.js file My code is for requirejs-config.js: var config = { config: { mixins: { '...
8
votes
4answers
17k views

Magento 2 : Override block file Magento\ConfigurableProduct\Block\Product\View\Type\Configurable.php

How to override function getAllowProducts() from Magento\ConfigurableProduct\Block\Product\View\Type\Configurable.php in magento 2. I want to override above function but not getting changes of ...
8
votes
2answers
3k views

How to handle deprecated “Mysql4” classes when rewriting resource models

I have to rewrite Mage_Catalog_Model_Resource_Category_Flat. The old resource class Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Flat is still there in Magento 1.7 for backwards compatibility and ...
8
votes
2answers
2k 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 ...
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
622 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
2answers
5k views

Magento 1 : how to override/rewrite a core controller class?

Note: This is intended as a canonical question that fully explains how controller rewrites work and can be used as duplicate target for more specific "How do I override controller X" or "Why does my ...
7
votes
6answers
5k 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 ...