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
7
votes
2answers
6k 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
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
4k views

Override Magento 2 JS file via requirejs-config.js not working

I'm trying to override the file vendor/magento/module-catalog/view/base/web/js/price-box.js in my theme using requirejs-config.js unsuccessfully. Location of my requirejs-config.js: app/design/...
7
votes
3answers
1k 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
1k 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
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
153 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
2k 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\...
6
votes
3answers
8k views

Magento2 - Override Magento/Checkout/view/frontend/web/js/view/shipping.js

How can we override Magento/Checkout/view/frontend/web/js/view/shipping.js file? I need to add some custom code to selectShippingMethod function so i can hide/show a block if a specific shipping ...
6
votes
1answer
6k views

Magento 2 : How to Override Admin Template File

I'm developing a custom module in magento 2. I need to change the file located in Magento/Sales/view/Adminhtml/Templates/Items/Column/name.phtml. How can I override file in custom extension?
6
votes
2answers
2k 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
2answers
6k 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\...
6
votes
1answer
1k 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
1answer
4k 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> ...
6
votes
2answers
8k 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 ...
6
votes
2answers
5k 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
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
2k 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
1answer
791 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
1answer
764 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 ...
6
votes
0answers
490 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
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 ...
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
3answers
640 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
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
449 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
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
991 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, ...
5
votes
1answer
342 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
3k 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 ...
5
votes
3answers
354 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
754 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
1answer
2k views

Override js core function in Magento 2 [duplicate]

in backend there is module-sales/view/adminhtml/web/order/create/scripts.js, and inside that js there is a function like this : loadShippingRates : function(){ this....
5
votes
1answer
2k views

How to override template files in a module

I have two template files that I need to override in a custom module. Those files are app/design/frontend/<current-theme>/template/catalogue/category/view.phtml app/design/frontend/<your-...
5
votes
2answers
83 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="...
5
votes
1answer
531 views

Override Available shipping method template from custom module not working

I tried to override the core template file which located in app/design/frontend/base/default/template/checkout/onepage/shipping_method/available.phtml like this: app/code/local/Test/...
5
votes
1answer
4k views

Override and extension class which in turn overrides a magento core class

I have a requirement which would need me to write an extension that overrides a class from another extension which in turn uses the rewrite to override a core module. Whilst I have the feeling that ...
5
votes
0answers
803 views

Magento 2 -Override tax functionality to calculate tax on cost instead of price

I have checked below mentioned files to override tax functionality: \vendor\magento\module-tax\Model\Sales\Total\Quote\Tax.php \vendor\magento\module-tax\Model\Sales\Total\Quote\CommonTaxCollector....
5
votes
1answer
169 views

Overriding Magento 2 core js function

I need to override the 'loadArea' and 'loadAreaResponseHandler' magento core js functions in the file module-sales/view/adminhtml/web/order/create/scripts.js. I tried to use mixin property. Following ...
4
votes
3answers
8k views

Redirected to the Homepage when removed www. from URL

Say, My Website is : www.example.com I have one page : www.example.com/contactus If I remove "www." from above url, means : example.com/contactus It redirects me to the homepage. Why ?? Checkout ...
4
votes
3answers
4k views

Magento 2: How to add Custom CSS/JS that will load last among other CSS/JS files

I need to override CSS/JS that will override the styling and I need it to load the last part among other CSS files link like: <head> <title>Home page</title> <link rel="...
4
votes
2answers
3k 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. ...
4
votes
2answers
9k views

How to override product list page [duplicate]

I'm trying to override the list product page. My objective is add certain information on each product above the add to cart button for example. I already did with the single page product, just ...
4
votes
2answers
795 views

Magento 2.1: <preference> doesn't work with block

I try to override getSelectionTitlePrice() - function. (vendor/magento/module-bundle/Block/Catalog/Product/View/Type/Bundle/Option.php) if i have understood right the best way to do it is use ...
4
votes
2answers
3k views

Copy core file to app/code/local/Mage can't overload!

I have 2 files need to be overload core/Mage/Admin/Model/Session.php and core/Mage/Adminhtml/controllers/IndexController.php I already copy it to local with same structure, but the bad news is it ...