Questions tagged [preference]

Denotes questions related to Magento 2 preferences

41 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6
votes
0answers
722 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>...
2
votes
0answers
66 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 ...
2
votes
0answers
93 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\...
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 ...
2
votes
1answer
153 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 ...
2
votes
1answer
722 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....
1
vote
1answer
34 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
1
vote
0answers
27 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
35 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\...
1
vote
1answer
198 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
428 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 ...
1
vote
2answers
93 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 ...
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:...
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 ...
1
vote
0answers
344 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 ...
1
vote
1answer
395 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
0answers
34 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
17 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
17 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
26 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
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 ...
0
votes
0answers
27 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
34 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
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
0answers
39 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:...
0
votes
0answers
38 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
46 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?
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
205 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
2answers
386 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 ...
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 ...
0
votes
1answer
480 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
179 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/...
0
votes
0answers
147 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\...
0
votes
1answer
72 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/...
0
votes
2answers
140 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
1answer
46 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? ...
0
votes
2answers
613 views

Catalog ProductList not overriding magento2

I have overridden my catalog product listproduct in etc/di.xml as: <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/...
0
votes
0answers
327 views

How to get Email Details from magento 2 using preferences

I need to get Email Details for recipients,Subject,body,header, so i wrote a preference to override a Sendmail class then, get email Details and follow my blow code: di.xml FIle: <?xml version="1....
0
votes
1answer
278 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/...