Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [interceptor]

The tag has no usage guidance.

0
votes
0answers
32 views

before plugin parameter magento 2

I am writing a before plugin for below public method. public function setup($user,$pass,$url = null){ $this->username = $user; $this->password = $pass; if ($url) { ...
1
vote
1answer
57 views

Unable to get newly inserted Product's Id using After Plugin for Catalog Product save controller method

I have created interceptor for catalog product controller's save action <type name="Magento\Catalog\Controller\Adminhtml\Product\Save"> <plugin name="ricky_catalog_save_product" ...
0
votes
0answers
14 views

interceptor has wrong interface

Im trying to override a plugin render function with a call to afterRender(); I need part of the existing function but that causes a Fatal error: Fatal error: Uncaught TypeError: Argument 1 passed to ...
2
votes
3answers
184 views

interceptor not generate for \Magento\Catalog\Block\Product\ListProduct

I'm trying to create plugin for getProductPrice but \Magento\Catalog\Block\Product\ListProduct Block Class not generate Interceptor Class like Magento\Catalog\Block\Product\ListProduct\Interceptor. ...
0
votes
1answer
81 views

Create an Interceptor/Observer to trigger action when specific page is loaded

I want to send info to third party services about the views on pages like cart, products, checkout, etc. This info is sent whenever someone visits the respective page or view. For example, when a ...
2
votes
1answer
101 views

Compilation error due to final class Vault in Magento version before 2.2.0

I am writing a plugin on class Magento\Payment\Model\MethodInterface: <type name=“Magento\Payment\Model\MethodInterface”> <plugin name=“mageworx_ordereditor_change_title_print_order” ...
0
votes
1answer
37 views

Where to place magento 2.2.x custom interceptor

I am trying to look for a proper document where it is clearly told about where to place my interceptor code for continuous programming This document https://devdocs.magento.com/guides/v2.2/extension-...
0
votes
1answer
280 views

Magento2 plugin/interceptor not working

I have following action: http://localhost/admin/catalog/product_attribute/edit/attribute_id/135/key/…/ I would like to do some extra things with attribute after saving. I have created and registered ...
1
vote
1answer
215 views

Remove plugin (interceptor)

I want to prevent a certain plugin from loading, namely 'authorization' plugin in module-quote/Model/GuestCartManagement/Plugin/Authorization.php. What i tried to do is to comment lines in di.xml ...
1
vote
1answer
237 views

plugin to stop redirecting to cart from checkout

In M2 if the user tries to go to the checkout without any items in their cart the Magento\Checkout\Controller\Index\Index::execute() function redirects them to the cart. if (!$quote->hasItems() || ...
0
votes
1answer
98 views

How to stop Interceptor class rewriting return annotations

Magento version: 2.2.3 I have a Block class with a method to fetch the designer associated with a product. It is annotated to return a model interface or null. public function getDesigner(): ?...
0
votes
2answers
64 views

Why is Magento 2 creating this Interceptor file?

I've been comparing two versions of a website I'm working on -- one is fine and the other has a broken layout -- and the main difference I've found between them is the following file: generated/code/...
0
votes
0answers
118 views

Interceptor error in Observer

vendor/magento/module-sales/etc/events.xml <event name="sales_order_save_after"> <observer name="sales_order_save_after" instance="Magento\Sales\Observer\SalesOrderSaveAfter" /> </...
2
votes
1answer
42 views

Is it better to use solely around function instead of before+after combined?

The codes below can achieve the same output: Using solely around plugin public function aroundXXX( SomeClass $subject, \Closure $proceed ){ beforeFunctions(); /*Perform XXX*/ $...
1
vote
1answer
185 views

How to stop saving resource model and throw error messages inside _beforeSave function?

I have the following codes inside a custom resourceModel class: protected function _beforeSave( AbstractModel $object ) { //My operations return parent::_beforeSave($object); } I added a ...
0
votes
1answer
33 views

Problem with widgets in Magento 2.1.9

I'm getting the next message when I try to add a widget on a block; Insert Widget... There has been an error processing your request Class Magento\Widget\Controller\Adminhtml\Widget\Index\...
1
vote
2answers
244 views

Magento 2 - Select the interceptor/observer

I want to have products that not require to stay logged and other that need it. So i think the best way is set in the admin "Allow Guest Checkout = Yes" and when the client goes to the checkout and ...
0
votes
1answer
1k views

Magento 2 using around interceptor/plugin to modify exception message

In the Magento\Checkout\Model\PaymentInformationManagement::savePaymentInformationAndPlaceOrder() method all exceptions are caught and CouldNotSaveException is created with a generic message. I ...
4
votes
1answer
1k views

Plugin, get original function parameters in after method

When creating plugin (http://devdocs.magento.com/guides/v2.0/extension-dev-guide/plugins.html) is there a way to get original parameters in after method? I'm not sure what i can find in the first ...
4
votes
1answer
447 views

Where is Magento\Framework\App\FrontController\Interceptor?

I am learning magento 2.1 request flow. I am stuck here: $frontController = $this->_objectManager->get('Magento\Framework\App\FrontControllerInterface'); $result = $frontController->...
2
votes
1answer
215 views

Magento 2 getProductCollection Interceptor everytime

I would like to intercept and modify a product collection every time it is used. However, I am having issues figuring out what functions to create a plugin for. I mostly understand Interceptors, ...
1
vote
0answers
63 views

Has anybody used Plugins(Interceptors) for Magento 1 from SafeMage Team? [closed]

everybody! Could anybody tell me if he use Plugins(Interceptors) from this team? http://www.safemage.com/function-plugins-for-magento-1.html It seems it is similar to the same functionality of ...
2
votes
1answer
2k views

Magento 2 : Use plugin / interceptor on abstract class

I am trying to create a plugin that fires after \Magento\Sales\Controller\Adminhtml\Shipment\AbstractShipment\PrintAction::execute. So I have my plugin setup in di.xml and an afterExecute() method, ...
1
vote
1answer
142 views

Sharing data between interceptor (plugin) and block. How?

I want to use some data from intercepters in a block. To start with I have attempted to use DI to inject a simple custom model but by logging I see that a instance is been used by the interceptor ...
2
votes
1answer
2k views

Interceptor error in Controller magento2

Vendor\Module\etc\di.xml <preference for="Magento\CatalogSearch\Controller\Result\Index" type="Vendor\Module\Controller\Result\Index" /> Vendor\Module\Controller\Result\Index.php namespace ...
2
votes
2answers
130 views

Add same plugin to all public methods of a type

Is there any chance to add a plugin to all public methods of a type without writing a separate method for all of them? I would like to use that to log method calls. The original method is always ...
1
vote
1answer
177 views

Plugin for coupon codes

I have added a plugin which should be triggered when a coupon code is applied. Sadly nothing happens, no errors too. Where did I go wrong? <?php namespace Zygis\TestModule\Plugin; class ...
1
vote
1answer
141 views

How to log Magento2 interceptors (plugins)

I want to get a list of interceptors and the order that they are dispatched. I also need to get the module name of each interceptor. I'm thinking of logging straight from the Magento\Framework\...
21
votes
1answer
4k views

Magento 2: what are the Interceptors file in var/generation?

So I noticed some Interceptor.php files in var/generation I know that this folder contains generated classes created on the fly for the following: Factories Proxies Plugins I assume that ...
3
votes
0answers
281 views

Magento 2 setup:di:compile exclude folders [duplicate]

Is it possible to exclude folders for a Magento 2 extension to be able to support Magento 2 compile command? Currently setup:di:compile throws errors that parent classes not found as they are loaded ...
1
vote
1answer
108 views

Plugins for intercepting methods with a negative sort order?

Within your di.xml you can add plugins to intercept methods of injectable classes. You can also specify a sortOrder. Can this ordering be negative, like -1? We guess so, but would like to know if ...
31
votes
3answers
6k views

Magento 2: Plugin before/around/after Interaction

In Magento 2, when you create an "around" plugin public function aroundRenderResult( \Magento\Framework\Controller\ResultInterface $subject, \Closure $proceed, ResponseHttp $response ) { ...
3
votes
1answer
3k views

Magento 2 - What is file Interceptor.php?

When I overrided file controller of catalog/product and ran this command: php bin/mangento setup:di:compile And then this file "Interceptor.php" was generated in magento_root\var\generation\myPool\...
1
vote
1answer
192 views

Why intercepter files are generator generation\Magento\Framework\View\Result\Layout\interceptor.php?

I have Magento 2 with sample data and I came across this file generation\Magento\Framework\View\Result\Layout\interceptor.php. The Interceptor file is generated only if any module wants to ...
0
votes
1answer
330 views

Plugin for ShippingMethodManagement no longer called when upgrading from Magento 2 beta4 to 2.0.0 release

I upgraded from the beta4 to the Magento 2.0.0 release. Now, I plugin I defined is no longer executed. My app/code/Example/Product/etc/frontend/di.xml looks like this: <?xml version="1.0"?> &...
3
votes
1answer
1k views

Magento 2: Intercept controller's JSON response

I'm trying to intercept a controller returning a JSON object of Magento\Framework\Controller\Result\Json class. The problem is that no matter if I use a plugin or a preference to "catch" the ...
7
votes
1answer
879 views

Magento 2: Why Does My Custom Controller Generate an Interceptor?

I recently created a basic routing configuration for a test module <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/...
17
votes
3answers
1k views

What Classes are “Intercept-able/Plugin-able” in Magento 2

Date: May 30, 2015 (given the changing nature of Magento 2). Magento 2 introduced a plugin concept, implemented via an interceptor pattern. What's not clear from the docs is -- which classes and ...
9
votes
3answers
944 views

Does interception in magento2 replace observers in magento1?

Is interception intended to be the preferred method when dealing with changing the behavior of an original method in Magento2 as observers was in magento1? https://wiki.magento.com/display/MAGE2DOC/...