Skip to main content

Questions tagged [after-plugin]

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

25 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4 votes
0 answers
83 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
3 votes
1 answer
1k views

Argument passing error in after plugin

I am trying to create after plugin for delete function of Magento\Tax\Model\TaxRuleRepository function looks like follows public function delete(TaxRuleInterface $rule) { $ruleId = $rule-...
Anshu Mishra's user avatar
  • 8,990
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
  • 385
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,368
1 vote
2 answers
2k views

Magento 2 Plugin After Execute Controller

I have an existing controller that returns a JSON. public function execute() { $customer = $this->_customerModel->getById(175); $resultJson = $this->resultFactory->create(\...
V Salvador's user avatar
1 vote
0 answers
139 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
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
1 vote
0 answers
645 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
1 vote
0 answers
117 views

How to insert a text into before all magento notification messages in magento 2 with plugin?

I'm new Magento. Can someone tell me how to insert a text into before all system messages of Magento 2 with a plugin. When I do anything, I get the message.Ex :login, create account, add to cart,...
Thành Trung Tô's user avatar
1 vote
0 answers
70 views

Magento2 Plugin for beforeExceute that return a $resultRedirect->setPath('customer/account/login');

I've to "override" a module that manage a redirect. The original module have this code: public function execute() { [...] $resultRedirect = $this->resultFactory->...
nino.aratari's user avatar
0 votes
0 answers
72 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
0 answers
179 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
1 answer
22 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
0 votes
0 answers
151 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
  • 455
0 votes
1 answer
377 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
0 votes
1 answer
514 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
1 answer
361 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
57 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
0 votes
0 answers
225 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
249 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
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
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
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,951
0 votes
0 answers
213 views

How to get popup on button click via plugin at admin side in Magento 2

I have "New Add Product" button at Sales->Order->Create New Order which I added through plugin. My di is at: etc/adminhtml As <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
Ajwad Syed's user avatar
  • 1,591
-1 votes
1 answer
78 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