Questions tagged [preference]

Denotes questions related to Magento 2 preferences

Filter by
Sorted by
Tagged with
0
votes
1answer
45 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
161 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 ...
0
votes
2answers
559 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/...
3
votes
1answer
923 views

Magento 2: controller preference not working after setup:di:compile

I need to rewrite a couple of adminhtml controllers in Magento 2. I am using preference and my configuration in etc/di.xml file looks like this: <?xml version="1.0"?> <config xmlns:xsi="http:...
1
vote
1answer
872 views

Overriding Sales\Block\Order\View Block in Magento 2

I am trying to extend Magento\Sales\Block\Order\View by using preferences to get some more information into customer order view page. Everything works fine if i remove __construct. so what might be ...
21
votes
2answers
5k views

Magento 2: what is the $data array constructor parameter?

So I noticed that in most models and blocks, there's this array $data = [] given as the last parameter of the constructor. For example \Magento\Catalog\Block\Product\ListProduct public function ...
0
votes
1answer
1k views

How to override core helper in magento 2?

I writed a preference for class Magento\Catalog\Helper\Image but i got this error: Recoverable Error: Argument 4 passed to Magento\Checkout\Block\Cart\Sidebar\Interceptor::__construct() must be ...
4
votes
1answer
2k views

Magento 2, override \lib\ classes

Can you override the classes in \lib\internal\Magento\Framework and if so how? I know how to use plugins/preferences to override the classes in \code but these methods do no seem to work with the lib ...
0
votes
0answers
298 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....