Questions tagged [preference]

Denotes questions related to Magento 2 preferences

Filter by
Sorted by
Tagged with
0
votes
2answers
54 views

Magento 2 : Magento\Newsletter\Model\SubscriptionManagerInterface class does not exist in 2.3 version. Need Compatible code for 2.3 and 2.4

I have installed a custom module related newsletter, I want my module to be compatible in 2.3 and 2.4. I'm overriding the class Magento\Newsletter\Controller\Subscriber\NewAction MyVendor/MyModule/...
0
votes
1answer
31 views

Magento2.4 How to override \Magento\Checkout\Controller\Cart?

Even if I simply copy the file without changes, it does not work as a preference. Any idea why? I created a preference in di.xml <?xml version="1.0"?> <config xmlns:xsi="http://...
0
votes
1answer
23 views

What's the difference between a XML preference with slash and without it?

Checking the Magento core I see two patterns a class with the slash in the beginning and a class without it. What would be the difference?
0
votes
1answer
29 views

Overriding Third Party Component code - preference

I am using an extension that displays a message as the customer approaches a Free Shipping threshold (https://aheadworks.com/free-shipping-bar-extension-for-magento-2), eg, "30 euro left until ...
0
votes
2answers
33 views

Magento 2 - Can't override class - must be an instance of

I created a preference override for Magento\Quote\Model\Quote\Item\CartItemPersister in my own module. But I get this error in the browser developer console: Total: Type Error occurred when creating ...
0
votes
0answers
16 views

magento 2.4 multiple modules override the same block class

I have the following situation: third party module A overrides core block php class via preference in order to customize a method the original method gets the input, loops it to extract some data, ...
0
votes
1answer
18 views

How to override a method of a class where the method itself is defined in its parent class, and only called in the current class?

I would like to extend the OrderSender class, located at Magento\Sales\Model\Order\Email\Sender\ and then override the method prepareTemplate($order), this method is actually defined in the Sender ...
0
votes
1answer
24 views

Preference seems to be ignored

This is the class I want to get preferenced : Amasty\Shopby\Block\Navigation\Top\Navigation I've put some dump inside each files....only the test 3 is appearing when it shouldn't as ovverrided by the ...
0
votes
3answers
44 views

Is it possible to override methods with arguments using preference?

I want to disable verification email sending from certain route. At first, I thought that I would create a plugin which would change the customer email to the dummy one before actually sending the ...
0
votes
1answer
63 views

Magento 2.4 Preference on Block does not work

What i'm trying to do is to rewrite a core function of ( MagentoMagento\ConfigurableProduct\Block\Product\View\Type\Configurable ) The function is called getJsonConfig() public function getJsonConfig(...
0
votes
1answer
28 views

Magento 2 preference not working for Magento\Customer\Model\Metadata\Form\File

I want to create preference for this file Magento\Customer\Model\Metadata\Form\File but its not working so please give some solution for this problem how to solve it di.xml code
0
votes
0answers
39 views

Override core file using preference not return value

I am trying to override my core file using preference, Note : I am override vendor\magento\module-wishlist\CustomerData\Wishlist.php Module: app\code\Zero\WishlistBrand\registration.php <?php \...
0
votes
1answer
86 views

Magento 2 cannot override 3rd party controller

Im trying to override a controller from swissup/firecheckout location in my vendor folder my di.xml is <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-...
0
votes
0answers
57 views

Magento 2 preference not working for classes that are being extended

i am trying to override _beforeLoad() on Magento\Eav\Model\ResourceModel\Form\Attribute\Collection this is being extended by Magento\Customer\Model\ResourceModel\Form\Attribute\Collection so i ...
0
votes
1answer
45 views

Magento 2 preference not working

I created a preference, if I try to exit the extended class nothing happens. But if I try it with the following code: <?php require_once 'app/bootstrap.php'; $bootstrap = \Magento\Framework\App\...
0
votes
0answers
17 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
76 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
89 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
119 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
42 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
499 views
1
vote
0answers
29 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.
1
vote
2answers
236 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
36 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 ...
1
vote
2answers
49 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
49 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 ...
1
vote
2answers
579 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
1answer
326 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:...
1
vote
1answer
461 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
436 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
277 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
778 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
733 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
520 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
65 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
190 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
783 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
242 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
230 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
74 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
154 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
355 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
229 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
283 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
72 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
104 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
4answers
252 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
592 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
124 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
71 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 ...