Questions tagged [preference]

Denotes questions related to Magento 2 preferences

Filter by
Sorted by
Tagged with
0
votes
0answers
13 views

Suddenly Sitemap model stopped working after 4month

I have used the preference to override the Sitemap model. Working fine for 4 months. I have also tried to find other module is overriding the same but didn't get anything. Can somebody help me to find ...
1
vote
1answer
28 views

Override Magento\Sales\Model\Order\Email\Sender\CreditmemoSender Magento 2

How to override below file in module ? Magento\Sales\Model\Order\Email\Sender\CreditmemoSender.php
0
votes
0answers
25 views

Magento 2: Override Magento Framework class Not working

I want to override this class function in Magento 2 \Magento\Framework\HTTP\PhpEnvironment\Request::getServer() etc/module.xml <module name="Test_Override" setup_version="1.0.0"&...
0
votes
2answers
44 views

How can i override abstract class protected function

I want to override abstract class Magento\Sales\Controller\Adminhtml\Order\Create of the below method protected function _processActionData($action = null){ } I have tried using preference but it ...
0
votes
2answers
32 views

What is the error in this Preference?

Due to PayPal Error, i am updating the following function in app/code/Magento/Paypal/Model/Api/Nvp.php, not edit the entire code just update a single function. Function Name : function ...
0
votes
1answer
138 views
0
votes
0answers
12 views

I have override the block Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option but is not working

I have followed this Magento2 - How to override this file Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Options.php but its now working.
0
votes
2answers
105 views

Magento 2.3 - How to handle Preference Error - Type Error occurred when creating object

I am using Magento 2.3.4 small bug in it (LINK) then Update the following code https://github.com/magento/magento2/blob/db69693bd929bd8665015ff6d9b6a3845584aa0b/lib/internal/Magento/Framework/Search/...
1
vote
0answers
25 views

Preference is not working while a method called from child class

I created a preference for the method _applyOptionsPrice() in Magento/Catalog/Model/Product/Type/Price.php class. The preference is working while the _applyOptionsPrice() was called from the same ...
0
votes
0answers
36 views

Magento 2.3.5 - Overriding registerRefundNotification in Magento\Sales\Model\Order\Payment.php

I'm trying to override the registerRefundNotification function to stop credit memos from automatically being created for refunds. My di.xml file: <?xml version="1.0"?> <config xmlns:...
1
vote
2answers
29 views

Cannot override class RuleProductPricesPersistor in Magento 2

I'm trying to override following class Magento\CatalogRule\Model\Indexer\RuleProductPricesPersistor Using below code <preference for="Magento\CatalogRule\Model\Indexer\...
0
votes
0answers
36 views

magento2 preference not working in Enterprise Edition 2.3.5

magento2 while overriding class using preference, its not working in Enterprise Edition 2.3.5 In checkout_cart_index.xml <referenceBlock name="checkout.cart.crosssell"> <action ...
0
votes
0answers
43 views

Magento 2 - Debug (Log) non-public functions

Intro Magento 2 recommends mostly using Plugins, but it is rather restrictive - you can mostly just use plugins for public functions. So, then we have preference for overriding classes and their ...
0
votes
0answers
520 views

Magento 2.3 - Display text Instead of 0 for 0 Price products

For my Magento 2.3.3 store lot of products ASK Price condition, How efficiently achieve this case, Anyone helps me with preference or module?
1
vote
1answer
165 views

Magento2 Around Plugin vs Preference. Which option is better?

I think I don't need to explain in detail about plugins, preferences and observers. These are types of overriding or extending default magento functionality. While overriding any magento core method/...
0
votes
0answers
14 views

magento2: I use di.xml to orverwrite vendor function but still run vendor function

It's code in di.xml. <preference for="\Magento\Customer\Model\Address\AbstractAddress" type="Forkel\CustomShipping\Model\Address\AbstractAddress" /> My file Forkel\CustomShipping\Model\...
0
votes
1answer
179 views

Overriding \Magento\Quote\Model\ShippingMethodManagement not successful

I've created a module to override di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:...
0
votes
0answers
124 views

Magento 2 Override a type used in virtual type

So, I'm trying to override a class that is used to create a virtual type, which is used as a preference for another class (see the Core di.xml below). I have posted the excerpt from my di.xml as well....
1
vote
1answer
182 views

Magento 2 Overide public static method of framwork class

I want to override public static function getCorrectFileName method of Magento\Framework\File\Uploader, I have check with Preference and Plugin but it is not working for me. Anyone have idea about ...
1
vote
1answer
295 views

Magento 2.3 - Swatches Helper override

I'm trying to override a function in the Helper of the Swatches module of Magento 2. The function resides in the Data.php file. As some of you may know in specific versions of Magento 2 the text ...
1
vote
3answers
164 views

Magento 2.3.3 : How to Overide Collect method in Magento\Catalog\Ui\DataProvider\Product\Listing\Collector\Image

I Have created recently viewed product widget in backend category page sidebar. I have single store with multiple Currency setup when i view the product gets added to list perfectly. My problem is ...
0
votes
1answer
417 views

How do you override Magento\Catalog\Block\Category\View?

I want to override the protected function _prepareLayout() So i have used preference <preference for="Magento\Catalog\Block\Category\View" type="Module\Name\Block\Category\View"/> class View ...
0
votes
2answers
338 views

Magento 2: Preference is not working

I want to override Magento\Catalog\Model\ResourceModel\Product\Collection using preference to modify the _buildClearSelect($select = null) method. For this, I have created di.xml with the following ...
1
vote
1answer
416 views

Magento 2-Override FinalPriceBox using Preference or Plugin class of Configurable Product module

Anyone has idea how to make preference or plugin on Magento\ConfigurableProduct\Pricing\Render\FinalPriceBox class of Magento\ConfigurableProduct. Basically, new function i wanted to add in the ...
0
votes
1answer
41 views

Is there a way to declare preference for a model or overwrite a model alias in M1?

I'm using Magento 1.9.x EE. I'm looking to overwrite the Mage_Core_Model_Email_Template::send function. I could overwrite the core class, but then my changes would be dependent on code that resides ...
1
vote
1answer
136 views

How to override already override class in magento 2

Hii we need to override Magento\Catalog\Model\ResourceModel\Product\Collection class for our customisation. To do this we added <preference for="Magento\Catalog\Model\ResourceModel\Product\...
0
votes
1answer
421 views

Some of product detail page error- Element 'reference': This element is not expected

When I tried to change or open product I got next message: 1 exception(s): Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'reference': This element is not expected. Line: 1 ...
0
votes
1answer
181 views

How to change shipment PDF font style in Magento 2.2.7

I am working on Magento 2.2.7 & need to change font style of shipment pdf i want to achieve that using preference way of di.xml file how to do that. which files,function i have to override ?
0
votes
1answer
175 views

Why preference not working in Magento 2 observer (Custom module)

etc/di.xml <preference for="Custom\Pricerule\Observer\Frontend\Catalog\Catalog\ProductGetFinalPrice" type="Lof\RequestForQuote\Observer\ProductGetFinalPrice2" /> observer/...
2
votes
0answers
65 views

Preference for Magento\Setup Classes not working

TLDR - Is there a reason I can't use preference for classes in Magento\Setup namespace, specifically during the setup:upgrade processing, OR is there something I am missing with the following ...
1
vote
2answers
87 views

How to use a preference for only one website when there is multisite functionality magento 2?

I have created a preference to override the functionality of customer save. But the I need to use the core customer save functionality for 1 website and my preference functionality for another ...
0
votes
2answers
236 views

Preference for ConvertToCsv not working in custom module

I have below code in my di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/...
2
votes
1answer
188 views

Preference class doesn't work

I'm trying to replace a class method "wrapResult" from: \Magento\Catalog\Pricing\Render\FinalPriceBox Never enter into this method. Try to stop the execution with die () or with xdebug, enter ...
0
votes
0answers
139 views

Error Class not found before deleting generated folder

I have created a preference to override a class but constantly getting error "Class not found" before deleting "generated" folder content: Error: Fatal error: Uncaught Error: Class 'Vendor\Module\...
1
vote
1answer
57 views

How to override List.phtml and Block as well

I'm trying to override the List.phtml and its block using preference I tried this <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:...
0
votes
1answer
69 views

How to override Quick Order model

I'm working on a Magento 2.2.3 B2B, with the Quick Order feature enabled, and I can't find a way to extend a method of the Magento\QuickOrder\Model\Cart model. So far I tried the usual: MyCompany/...
5
votes
2answers
155 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="...
3
votes
1answer
359 views

Undo preference from third party module

I have to deal with a third party module that enthusiastically uses preferences for everything and breaks stuff with it. For example: <preference for="Magento\Sales\Model\Order" type=&...
2
votes
0answers
90 views

Is it possible to change/replace the custom function argument in magento 2

I just want to change/replace the custom function arguments, not constructor arguments. This is third party module function, which have wrong argument. public function addAttachment(\Fooman\...
1
vote
3answers
68 views

How to Make Class or module to support M 2.1.7 and M 2.2.4 version in Magento 2

I have one custom module which is working fine for M 2.1.7 in that module, I extend \Magento\Bundle\Model\Product\Type in M 2.2.4 they added a new class for core file and passed to __construct ...
0
votes
2answers
124 views

How to call Plugin which already using the preference for vendor file in magento 2

How to call Plugin which already using the preference for vendor file in magento 2. I have already has preference which is overridding the some custom Magento controller, Now how can i use plugin to ...
0
votes
2answers
227 views

Private method error while overriding Magento\Customer\Model\ResourceModel\CustomerRepository

I am using <preference> to override CustomerRepository, but Magento\Customer\Model\ResourceModel\CustomerRepository contains private functions and it throws me error Fatal error: Call to ...
0
votes
4answers
2k views

Magento 2, preference for Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection does not work

When filters + Ancor is enabled for category, sorting by product name doesn't work. I know the fix as I tested in Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection. So now I'm trying to ...
0
votes
1answer
39 views

Overriding Custom module's controller in Magento2 giving error

I am trying to override the controller of an extension in Magento2. My di.xml file is:- <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
2
votes
0answers
87 views

Why is there a DI preference for ProductInterface?

The ProductInterface has a DI preference leading it the ProductModel. While ProductModel is marked as falling under the Backward Compatibility Standard (it is marked with @api), it is still belonging ...
1
vote
0answers
343 views

Custom Module - Cart Page shows only “Estimate Shipping and Tax”

I'm trying to overwrite the function setRequest in /vendor/magento/module-usps/Model/Carrier.php to request "Online" rates from USPS. My complete module code is below. My module is enabled. I ...
0
votes
1answer
293 views

is it possible to override core plugin method by custom preference method?

is possible to override core plugin method by preference? Means I need to override afterXyz method in my module by using preference.
0
votes
4answers
7k views

Magento 2 Extend class with custom method through preference doesn't work

I'm trying to add a custom method Magento\LayeredNavigation\Block\Navigation. To my knowledge preference is the only way to do that. My di.xml <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-...
3
votes
2answers
943 views

Magento 2 not respecting preference?

I'm trying to make a preference to override the PayPal Module's ResponseValidator class, so that i can save the validation errors for easier debugging on our end if a customer's checkout fails. The ...
1
vote
1answer
481 views

Dependency injection not working on one the the tax collector class

I am trying to override mapItem method from "Magento\Tax\Model\Sales\Total\Quote\CommonTaxCollector" using below code. However code written in my local module's class is not invoked. VendorName\Tax\...