Questions tagged [preference]

Denotes questions related to Magento 2 preferences

Filter by
Sorted by
Tagged with
1
vote
1answer
38 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
11 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
30 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
21 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
48 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
78 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/...
1
vote
0answers
27 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
34 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
69 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
51 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
31 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
41 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
26 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/...
4
votes
2answers
67 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
vote
1answer
72 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="Censored\...
2
votes
0answers
44 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
62 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
39 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
80 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
3answers
606 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
32 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
81 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
280 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
214 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
2k 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
552 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
363 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\...
4
votes
1answer
210 views

How to override _registerJsPrice($price) function in Configurable.php Block in Magento2?

I am trying to override __registerJsPrice($price) function in configurable.php This function is work when we change swatch. Path of configurable.php is /opt/lampp/htdocs/magento/vendor/magento/...
2
votes
2answers
348 views

Magento 2 - Override Model Failed

I try to override the Customer model. I created code/Tc/Name/etc/di.xml, code/Tc/Name/Model/Customer/Customer.php . In di.xml <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ...
0
votes
1answer
209 views

Magento 2: Get product ID in override getTierPriceList from TierPrice

I'm extending \Magento\Catalog\Pricing\Price\TierPrice to return a custom list of tier prices for products. But I can't seem to figure out how to get the product id that is calling the ...
6
votes
0answers
409 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>...
3
votes
3answers
1k views

How to overwrite \Magento\Framework\Config\File\ConfigFilePool

Short version: How to use custom db and module config files instead of env.php and config.php ? or How to completely overwrite \Magento\Framework\Config\File\ConfigFilePool ? Long version: I'm ...
2
votes
1answer
109 views

How to override UpgradeData.php with Factory?

I need to override the UpgradeData Class from Catalog\Setup\UpgradeData But the constructor has factories in his arguments like CategorySetupFactory When I run setup:di:compile I got an error that ...
1
vote
1answer
304 views

how to intercept PayPal IPN messages

I was trying to understand what's the best way to read incoming IPN messages from PayPal. This need comes from the order workflow we implemented in our website. For example: when a payment is ...
0
votes
1answer
230 views

Why is my Magento Catalog Block Preference ignored in di.xml?

I am trying to extend the Magento\Catalog\Block\Product\ListProduct block in Magento 2.1 My Vendor_ModuleName module has the registration.php, the etc/module.xml and it's enabled. Then I add an etc/...
2
votes
1answer
224 views

How to extend creditmemo save action in magento 2

I need to extend creditmemo save action: Update post data before action method call Update database after creditmemo save. Which method is better Plugin or preference and if Plugin then how can I ...
4
votes
2answers
835 views

Magento 2: preference not working in admin panel

I am trying to override ConfigurablePriceResolver but can't override app/code/vender/module/etc/di.xml <?xml version="1.0" encoding="UTF-8"?> <config xmlns:xsi="http://www.w3.org/2001/...
2
votes
1answer
563 views

How to Override Payment Helper Data Method Magento 2?

I am trying to override Magento Payment Helper data in my extension but it's not working. I have overriden by using the preference method. I have put below code in app/code/Demo/PaymentTest/etc/di....
3
votes
1answer
222 views

Magento 2 preference not working for Magento\Checkout\Block\Onepage

I am trying to override Magento\Checkout\Block\Onepage and it's display blank page Here is my Mymodule/Test/etc/di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/...
0
votes
1answer
512 views

Why preference is not working in Magento 2?

I am trying to implement error report in magento 2 so for that purpose i would like to mail all the errors in email. So I started with prefernece. di.xml <?xml version="1.0"?> <config xmlns:...
1
vote
4answers
3k views

Preference is not working in Magento 2

I am trying to override ErrorHandler class using preference but it is not working. di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
4
votes
2answers
746 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 ...
8
votes
1answer
2k views

Magento 2: get a list of all plugins (interceptors) and preferences

Is there a way I can retrieve the list of all plugins (with the methods they're plugged onto) and all preferences (and their original class) on a Magento 2 install.
0
votes
1answer
308 views

What is the best way to override _initProduct() in module-checkout\Controller\Cart\Add.php

What is the best way to override _initProduct() function in: vendor\magento\module-checkout\Controller\Cart\Add.php I have this in my di.xml: <type name="Magento\Checkout\Controller\Cart\Add"&...
3
votes
1answer
714 views

Magento 2 override Pricing\Price\ConfigurablePriceResolver how to solve?

Hi I'm using Magento 2. I'm trying to override Pricing\Price\ConfigurablePriceResolver by adding a plugin or preference in the app/code folder but I can't make it work. I need to replace the ...
2
votes
1answer
52 views

Magento 2: Extend from rewritten block

Originally: There are 2 blocks like this: namespace Vendor\Module_1\Block; class ParentBlock{} class ChildBlock extends ParentBlock {} Now, I need to rewrite ParentBlock using di.xml: <...
0
votes
1answer
43 views

magento 2 preferences - what to extend

I have a question about m2 preferences (overwriting core modules). Whenever I overwrite a core module, do I have to inject all the classes the same way original class does? Also what should I extend? ...
1
vote
1answer
149 views

Overriding Block file is not working in Magento 2

Today I am trying to overwrite the \Magento\Sales\Block\Adminhtml\Order\View file, but it's not working. The same coding working on core files. My Code is <?php namespace SR\StackExchange\Block\...
2
votes
2answers
3k views

Magento 2: How to override Magento\Catalog\Block\Product\View constructor to inject \Magento\Eav\Model\Entity\Attribute\SetFactory

I am attempting to override the __construct method in the Magento\Catalog\block\Product\View block so that I can access the Magento\Eav\Model\Entity\Attribute\SetFactory to get the AttributeSetName of ...
5
votes
1answer
7k views

Magento2: plugin around method not working

I'm trying to use the plugin around method to override the execute method of \Magento\Checkout\Controller\Onepage\Success.php. I'm trying to create a module that allows you to view the checkout ...