Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [after-plugin]

Denotes questions about Magento 2 AfterPlugins. For general questions use "plugin" tag.

Filter by
Sorted by
Tagged with
1 vote
0 answers
17 views

ProductRepositoryInterface plugin how to join another table with sort option?

I need to add the most-viewed and best-seller sort options into the rest/v1/products API. I created a plugin to add sort condition for following of below link How to add custom sort like Most View ...
Devidas's user avatar
  • 3,358
-1 votes
1 answer
64 views

Access $this Data on plugin magento

i built an after plugin and i need to access data inside $this. In the image you can see the hierarchy. The problem is that i need to access to the id of the CompanyModel value (22). but inside $this ...
Francesco's user avatar
0 votes
0 answers
68 views

Changing product name for configurable product when being added to cart?

Magento 2.4.6 I am trying to change the name of a configurable product which is added to the cart. I figured that changing the getProductName function in \vendor\magento\module-configurable-product\...
user4095519's user avatar
0 votes
3 answers
96 views

How to persist the value of a custom field on the customer_entity table?

I'm new to Magento 2 and to this forum. I'm trying to add a newsletter subscription on the customer menu, just after the core one. For that, i created a module "ACME_Newsletter" I added a ...
jlegrand79's user avatar
0 votes
0 answers
144 views

Hot to create plugin for savePaymentInformationAndPlaceOrder method

This method is calling at checkout step but with plugin using after method it's not calling, core method is calling. etc/di.xml <type name="Magento\Checkout\Model\PaymentInformationManagement&...
Jimit Bhavsar's user avatar
0 votes
2 answers
757 views

Magento 2 Certification Question - How can a developer prioritize a plugin's execution, if possible?

How can a developer prioritize a plugin's execution, if possible? A. The developer can use sortOrder property by specifying a higher value than the target plugin. B. This cannot be achieved as the ...
Wakar Ahamad's user avatar
0 votes
1 answer
204 views

Display plugin result to product list page

I created a plugin file for showing some extra data on product detail page. May I know how to display the result to the product list? Thanks app/code/Myvendor/Mymodule/Plugin/GeoModel.php <?php ...
hill2011's user avatar
0 votes
3 answers
78 views

How to override taxvat.phtml

Hi dears I want to override taxvat.phtml in vendor > magento > module-customer > view > frontend > templates > widget Before I try to create a file Vendor > Module > etc > ...
Peren's user avatar
  • 27
0 votes
1 answer
21 views

Include shipping on quote item not quote

What I'm trying to achieve During the checkout, if the customer has a Bike item in their basket, we want the shipping cost to be added as a product option to the cart item as opposed to being added to ...
Richard Parnaby-King's user avatar
1 vote
1 answer
2k views

After Plugin - Is it compulsory to return result?

Original public function addOrderCommentsTo($order, $prevOrder) { //something } The original function doesn't return anything. Do I need to add return $result inside Plugin after ...
Sheri's user avatar
  • 140
0 votes
0 answers
147 views

magento 2.4 intercept execute and get saved object id

I have a frontend controller that submits a form the following way: the controller execute method is called this method takes the post values from the request, then first creates an empty object, ...
Lou Nik's user avatar
  • 453
1 vote
2 answers
2k views

Magento 2 Plugin After Execute Controller

Existing controller that returns a JSON. public function execute() { $customer = $this->_customerModel->getById(175); $resultJson = $this->resultFactory->create(\Magento\...
V Salvador's user avatar
0 votes
1 answer
966 views

Magento 2 Override third party Module function with Plugin

I am using third party module for print pdf and now I want to customize the one function with using plugin, currently I am using after plugin and able to print the result of original function in my ...
akgola's user avatar
  • 2,947
0 votes
1 answer
361 views

_initSelect override with Plugin in Magento2.4.1

Need a help in this issue. I am trying to remove a MySQL condition from _initSelect from this Collection "Magento\SalesRule\Model\ResourceModel\Rule\Collection". This Collection has the ...
Nithin's user avatar
  • 23
2 votes
2 answers
2k views

New Order Send custom email template in Magento 2.4

I have two condition :- First if customer is not approve send custom email template. Second if customer is approve send magento default email template. How can i achieve this. THANKS.
Mohit Patel's user avatar
  • 3,833
0 votes
2 answers
2k views

Magento 2 custom shipping method carrier is not showing after selecting the method from dropdown in order shipment backend

I have installed my Shipping Tracker module in Magento 2.3.5p1, I have added a custom Shipping method which is showing in the dropdown in the backend on the Order shipment page as below, Note: This ...
Mohit Rane's user avatar
  • 1,965
0 votes
1 answer
478 views

Restrict shipping method based on product attribute

I'm trying to restrict a shipping method in afterCollectRates based on a custom product attribute (which I'm injecting with the help of catalog_attributes.xml public function afterCollectRates(...
zlep's user avatar
  • 168
0 votes
2 answers
445 views

Magento 2.4 alter contact form post values using plugin afterExecute

I am trying to use a plugin to alter the contact form post data by using the afterExecute method: public function afterExecute(\Magento\Contact\Controller\Index\Post $subject, $result) { ...
sulman's user avatar
  • 529
1 vote
1 answer
480 views

About performance: Is better to use before and after plugin instead around always when possible?

About use of each kind of interceptor (plugin) was answered here: Is it better to use solely around function instead of before+after combined? But in Magento docs says: Avoid using around method ...
jefferson's user avatar
0 votes
1 answer
1k views

What's the correct way of having two different plugins for one method?

I have this afterGetList plugin in Vendor\Module\Plugin\Magento\Sales\Model\OrderCompanyAccount.php public function afterGetList( \Magento\Sales\Api\OrderRepositoryInterface $subject, $...
zlep's user avatar
  • 168
0 votes
1 answer
344 views

Magento 2 plugin not getting called on checkout for shipping

I am trying to preselect the shipping country based on the user's country code. I have the code already needed to get the country code which is in my model. I have tried using the code in accepted ...
AdRock's user avatar
  • 111
0 votes
1 answer
49 views

Create afterRevokeCustomerAccessToken plugin magento 2

di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/...
Hamendra Sunthwal's user avatar
1 vote
0 answers
136 views

Plugins prioritization

The documentation mentions the sort order is always from lowest to highest, except when around plugins are used, then The around plugin’s method affects the flow of all plugins that are executed ...
Bogdan Tomi's user avatar
2 votes
1 answer
3k views

Magento 2 - Write plugin for API interface

In the documentation it says: "A plugin, or interceptor, is a class that modifies the behavior of public class functions by intercepting a function call and running code before, after, or around ...
Black's user avatar
  • 3,379
0 votes
1 answer
228 views

Plugin for an existing plugin

Is it possible to create a plugin for an existing plugin class in Magento 2.3.5-p2 and if so, are there any special ways of doing this besides the normal plugin creation?
Petar Borisovski's user avatar
2 votes
1 answer
579 views

Execute after plugin: how to know no error occurred?

I'd like to plug an after plugin to the admin controller saving attribute data (Magento\Catalog\Controller\Adminhtml\Product\Attribute\Save) but this plugin should be processed only if no error/...
Man4x's user avatar
  • 23
0 votes
1 answer
1k views

How do i get createAccount methods argument in after plugin Magento 2?

I am writing after plugin on create account method, to change the API response with. I have to call createCustomerAccessToken($username, $password) function, which has two parameters. What I am ...
sudo55's user avatar
  • 1,004
0 votes
0 answers
217 views

Magento 2 Plugin on Magento\Store\Model\Store

How to check if a plugin really work? files are: app/code/Vendor/Module/etc/di.xml <?xml version="1.0" encoding="utf-8"?> <config> <type name="Magento\Store\...
krybbio's user avatar
  • 1,258
0 votes
0 answers
241 views

Extending Error handler using plugin method is not working

I need to save errors in my database. So I am trying to extend Error Handler in my custom module using plugin method. But it is not working. Here is my code di.xml <?xml version="1.0"?> <...
Geethu Jaison's user avatar
1 vote
1 answer
579 views

Magento 2 how to get get product ID in after plugin?

please help, I'm struggling with this. I'm using this plugin public function afterAddProduct($subject, $productInfo, $requestInfo = null) I'm trying to get the product Id of the product in this way:...
Oscar Vazquez's user avatar
0 votes
1 answer
195 views

Plugin always breaks the core Flatrate Shipping method

I have created a plugin to customize the Flatrate shipping(per order) when a guest checks out any product. Below are my relevant module-plugin files which I supposedly wrote as per Magento 2.x's ...
Vicky Dev's user avatar
  • 1,992
1 vote
2 answers
325 views

Magento 2.3.4 Plugin Sitemap not working

I've had a plugin working on 2.2.2 version but it's not working on 2.3.4. Its seem that collectSitemapItems() method is not firing even in native magento WHen I print_r('Die');die; public function ...
Juliano Vargas's user avatar
0 votes
1 answer
1k views

Plugin to change order status after payment capture

Currently Magento2 sets the order status to the default status of the state STATE_PROCESSING when a credit card payment is captured. This is done in vendor/magento/module-sales/Model/Order/Payment/...
2aptech's user avatar
4 votes
0 answers
82 views

Plugin to alter custom attribute value

To alter product price before displaying on frontend we can use Plugin afterGetPrice() same for Name afterGetName and so on for default product attributes. Is there any way to perform same for any ...
Piyush's user avatar
  • 5,904
2 votes
1 answer
998 views

Execute Plugin Class from specific module in Magento2

I have created a custom reports using ui components. For the export csv I have created a plugin class for this function. Vendor/Report1//etc/di.xml <type name="Magento\Ui\Model\Export\...
Manjunath's user avatar
  • 177
2 votes
1 answer
84 views

Cart page fatal error after creating a product collection plugin, Magento 2.3

We have a need to sometimes fetch product prices from an API for products loaded on the frontend. We figured it would be easiest to create a plugin for the collection: <?xml version="1.0"?> <...
MikeGrove's user avatar
0 votes
2 answers
334 views

Resourcemodel plugin not working - Magento2

app/code/Mymodule/Orderedproductsreport/etc/di.xml <type name="Magento\Reports\Model\ResourceModel\Product\Sold\Collection"> <plugin disabled="false" name="...
Jimit Bhavsar's user avatar
1 vote
0 answers
2k views

Magento 2 - How to call a protected function from the subject inside a plugin

I have created a plugin for a particular function. That function is also calling another protected function of the core file. public function afterPopulateTaxRateData( \Magento\Tax\Model\...
Mahi M's user avatar
  • 2,540
0 votes
2 answers
872 views

Magento 2 - Create a log file in plugin that will print log when data is inserted in database

I have entered data in the database using object Manager in Model file itself. I want to print a log file from the plugin that will print the log of the last data that is inserted in the database.
Naiwrita09's user avatar
1 vote
0 answers
635 views

How to extend store credit functionality in Magento 2 Enterprise Edition

I want to add amount as store credit by: -> API -> Using Payment Method By default store credit is added when we redeem gift card. But my requirement is to add store credit directly by customer ...
Ajwad Syed's user avatar
  • 1,591
2 votes
1 answer
387 views

Around Plugins ( Interceptors) in magento can be used to suppress before and after plugin execution?

In around plugin function, if we don't use proceed() then after plugin execution will be suppressed. Is there anyway by which we can suppress before plugin execution?
Mayur Vijay Kathale's user avatar
1 vote
2 answers
972 views

Can I access changed parameters in an after/around plugin?

I want to access a parameter of a method in an after plugin. The value of the parameter has been changed inside the original method, and I want to access the modified value. Example: class ...
hey's user avatar
  • 1,137
2 votes
2 answers
1k views

Override Shipping Rates at checkout

I am simply looking to get the shipping rates from the current quote and override them via a plugin/interceptor but have no idea where I'm going wrong here: <?php namespace Vendor\Module\Plugin\...
SNAFU's user avatar
  • 196
2 votes
1 answer
1k views

Magento 2 REST API: Get the name of child products in bundle_product_options-> product_links

So I am trying to go for a headless magento approach. I am using the following API to get product details: V1/products/:sku If the product is a bundle product, it shows bundle_product_options in ...
Fokker's user avatar
  • 375
0 votes
1 answer
2k views

Get Product info from afterAddProduct Plugin in magento 2

I have a custom functionality for add to cart in product detail page. Once button clicked, sending product id and adding product to the cart. Used below code to implement it. <input type="hidden"...
Jafar Pinjar's user avatar
  • 1,939
2 votes
1 answer
61 views

I cant seem to write an Plugin for \Magento\ImportExport\Model\Import\AbstractSource

I am trying to write a plugin for \Magento\ImportExport\Model\Import\AbstractSource::current using <type name="Magento\ImportExport\Model\Import\AbstractSource"> <plugin name="...
Alex's user avatar
  • 13.8k
0 votes
1 answer
67 views

Plugin method not found

This is my plugin: <?php namespace Vendor\Module\Plugin; use Magento\Email\Controller\Adminhtml\Email\Template\DefaultTemplate; class MyPlugin { public function afterExecute(DefaultTemplate $...
Rufus's user avatar
  • 621
1 vote
1 answer
358 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" ...
Kapil Dev Singh's user avatar
1 vote
1 answer
1k views

Magento 2.3.0 How to override wishlist & compare product list page using plugin

I want to override wishlist & compare product grid using plugin. after that i would like to append custom div under class="product-image-container". I try & search a lot but no luck. is there ...
Chirag Patel's user avatar
  • 6,136
0 votes
0 answers
1k views

Customer redirect issue with login post plugin magento2

I have used two plugins to use the referral url's for customer login page. here is the code of my etc/di.xml <type name="Magento\Customer\Controller\Account\LoginPost"> <plugin ...
Jafar Pinjar's user avatar
  • 1,939