2022 Developer Survey is open! Take survey.

Questions tagged [plugin]

Denotes questions about Magento 2 Plugins (BeforePlugin , AfterPlugin and AroundPlugin). Plugins are also known as interceptors in the Magento documentation.

Filter by
Sorted by
Tagged with
0 votes
2 answers
23 views

Magento Plugin for New Passwords

Is there any magento plugin that allows in the section of "password change" to restict the field "new password" not to accept values as in "current password"?
user avatar
  • 1
0 votes
1 answer
19 views

Magento 2 - why is my plugin for \Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder not working?

I try to write an after plugin for the method getItemOptions of the class \Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder Attempt: app/code/Company/Configurator/etc/di.xml ( I also tried app/...
user avatar
  • 2,402
0 votes
0 answers
10 views

Have a plugin (interceptor) run once per session

So, I have this plugin for our project (drop-shipping marketplace), which redirects vendors without signed contracts to the contract signing page. The thing is, as it is, it infinitely redirects ...
user avatar
0 votes
0 answers
22 views

Magento 2 how to show newsletter box on checkout success page

We are using Magento 2.4.0 version. We are able to show the Newsletter box on the checkout success page but after submitting the email it is redirected to an empty shopping cart. That code we are ...
user avatar
  • 1,123
0 votes
1 answer
57 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; in plugin after function and what if I ...
user avatar
  • 118
0 votes
0 answers
27 views

how to include extension attributes in rest API call of products?

I have made a drop-down named test_attribute and multi_attribute for products and I want to show that into API call of products as well I have made extension_attributes.xml but nothing in ...
user avatar
  • 3
0 votes
0 answers
31 views

Is it a bad practice to throw an exception in the plugin?

Let's say one wants to use a before plugin. Also let's say under a certain circumstance it is impossible to do so, therefore we want to throw an exception. However it doesn't feel right to do so; but ...
user avatar
0 votes
0 answers
45 views

Extend API V1/products to put the not available products at the end

I want to display out of stock products at the end of the V1/products response. So far I tried to create a plugin on Magento\Catalog\Api\ProductRepositoryInterface to override the getList method but ...
user avatar
0 votes
2 answers
52 views

Magento 2 - How to disable a plugin

Problem: I am using the extension Fooman_PdfCustomiser. I need to disable the plugin named fooman_pdfcustomiser_paymentinfoblock. vendor/fooman/pdfcustomiser-implementation-m2/src/etc/di.xml: <...
user avatar
  • 2,402
0 votes
0 answers
5 views

MFTF Adobe Commerce Supplied faild

I'm trying to pubish a new plugin for magento 2.4. When I upload the plugin to the magento marketplace the "MFTF Adobe Commerce Supplied" review fails. I got this message: ...
user avatar
  • 1
0 votes
1 answer
30 views

Magento 2 Error while canceling the order

I'm facing the below error while canceling the order SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`magentodb`.`...
user avatar
  • 1,838
0 votes
1 answer
110 views

afterExecute() must be an instance of Magento\Framework\App\Response\Http in plugin Magento 2.4 upgrade

I have a plugin in my module that was working in Magento 2.3, but after upgrade to 2.4 i am getting the error TypeError: Argument 2 passed to ..\Plugin\Controller\Checkout\Sidebar\RemoveItemPlugin::...
user avatar
  • 77
0 votes
2 answers
44 views

Why we need to add argument to plugin?

Recently I get through this below set of code and am not sure why the arguments are passed for the plugin. <type name="Magento\Framework\Mail\TransportInterfaceFactory"> <...
user avatar
  • 828
1 vote
1 answer
102 views

Magento 2.4 Sidebar\RemoveItem - afterExecute() must be an instance of Magento\Framework\App\Response\Http

I get this error: TypeError: Argument 2 passed to ..\Plugin\Controller\Checkout\Sidebar\RemoveItemPlugin::afterExecute() must be an instance of Magento\Framework\App\Response\Http, instance of ...
user avatar
  • 2,739
0 votes
1 answer
48 views

How to add custom password in magento 2

I am wanting to create a password record in the customer_entity table. And after the user creates an inviting account it will save the user password in it.this is my current code UpgradeSchema.php ...
user avatar
1 vote
0 answers
28 views

Magento 2 / Intercept Array REST API Call with a Plugin?

is it possible to intercept the sales order API array export to manipulate the array? I've installed the Amasty Extrafee Extention, but our Merchandise Management System cannot work with this export. ...
user avatar
0 votes
0 answers
14 views

creating a topmenu item through plugin but 'is_active' is not working as expected

I am trying to check for the routename and based on that i want to display the top menu item as active or not. But for some reason is_active does not do anything. Even when i jusst straight up set it ...
user avatar
0 votes
1 answer
49 views

Around plugin usage in Magento2

I have to override the file Magento\ConfigurableProduct\Helper\Data.php into my custom module I have few changes in the function getOptions public function getOptions($currentProduct, $...
user avatar
  • 135
0 votes
0 answers
16 views

How to modify the shipping-address form only at specific locations?

I modified the shipping-address form following this guide to show a legal text on top of the form: Add new field in address form I used a text field with a default value that gets translated for ...
user avatar
  • 17
0 votes
0 answers
12 views

Why does Magento docs show manipulating layout though plugin rather than module layout XML file

The docs https://devdocs.magento.com/guides/v2.4/howdoi/checkout/checkout_new_field.html they describe adding a new field to the checkout form. The first step is to get the field onto the form and ...
user avatar
  • 406
0 votes
0 answers
24 views

How to Save Custom Attribute value While Customer Login through REST API

I have created a custom attribute that is device_token and i want to take some value while customer login like in the below image. So what is the correct way to save that value in Magento 2 customer ...
user avatar
0 votes
0 answers
8 views

Salesforce + Magento Best Plugin

We're a luxury wholesale company who work with leading fashion retailers and are currently looking to integrate Magento and Salesforce. A two-way sync for creating new accounts/leads/editing customer ...
user avatar
0 votes
0 answers
24 views

Exception #0 (BadMethodCallException): Missing required argument $action

i got a problem with plugin. use Magento\Framework\App\Action\Context; use Magento\Framework\App\Request\DataPersistorInterface; use Orba\AfterContact\Api\Data\ActionControlInterface; use Magento\...
user avatar
0 votes
0 answers
10 views

Magento 2 + Salesforce API Integration

We are a wholesale business and would like to connect Magento 2 with Salesforce to have a 2-way synchronization. We're currently having issues finding a suitable and cost-effective API connection that ...
user avatar
0 votes
0 answers
31 views

Invalid security or form key. Please refresh the page, Grid Implementation

I had created a custom admin grid and when I enter the newly made grid in the admin catalog site, gives an error as in the title appears. Here is my index.php namespace Warsaw\Weather\Grid\Controller\...
user avatar
0 votes
1 answer
36 views

How to Create a Plugin with the method afterGetData on the class Magento\Framework\App\Http\Context in magento2?

How can I build this module for our Magento 2 for cache warmer to crawl both desktop and mobile version pages? We would like to create a plugin with the method afterGetData. On the class Magento\...
user avatar
0 votes
1 answer
23 views

Disable First & Last name in customer account and pass the existing value to POST

I want to prevent customers from changing their first and last name once they're registered but I want to allow them to change the password in a customer account. I added disabled = "disabled&...
user avatar
0 votes
0 answers
24 views

Magento2.3.5 how to add video tags to sitemap

Does anyone have any idea how to add the videos to the native Magento sitemap under each product? I'm looking at the file ../htdocs/vendor/magento/module-sitemap/Model/Sitemap.php I can see this ...
user avatar
0 votes
0 answers
51 views

Magento 2 : GraphQL Exception in Plugin

I'm trying to achieve a specific feature when customer can't add some combination of products in the cart (the last one have to be refused). For example, product A, B and C can't be on the same cart, ...
user avatar
  • 1
0 votes
2 answers
83 views

Magento 2 - Can't override class - must be an instance of

I created a preference override for Magento\Quote\Model\Quote\Item\CartItemPersister in my own module. But I get this error in the browser developer console: Total: Type Error occurred when creating ...
user avatar
  • 2,402
0 votes
0 answers
79 views

How to add a product with custom price to the quote with plugin [beforeSubmit] in Magento 2

I have a plugin to replace one of the products in the last step before a quote is submitted. I'm able to add a new product, remove the old one but I can't set the new product price to the price of the ...
user avatar
  • 15
0 votes
1 answer
30 views

How to execute clientside javascript from php plugin file

Is it possible to call a frontend javascript function from a plugin php file? The js function should be executed in the browser. view/frontend/web/js/send.js function send() { console.log("...
user avatar
2 votes
1 answer
62 views

Override method magento 2

I am using magento 2.4.3 EE version Is their any way to override below method protected function _calculate($rule, $item, $qty, $rulePercent) for below classes \Magento\SalesRule\Model\Rule::...
user avatar
  • 230
0 votes
0 answers
111 views

How to get $resultRedirect->setPath() data in afterExecute plugin

I have written a plugin for few changes and all working well. Now I want to get redirect data E.g setPath and main id in afterExecute plugin Here is my code <?php namespace Demo\Demo\...
user avatar
0 votes
2 answers
201 views

Get selected country id and region name in class LayoutProcessor of custom module

I have a custom module app/code/Learning/FirstUnit/ and in that i have LayoutProcessor.php file in app/code/Learning/FirstUnit/Plugin. Please see the below code in LayoutProcessor.php <?php ...
user avatar
0 votes
1 answer
34 views

magento 2 Unable To get Product Attribute

I am trying to fetch product attribute on cart page but it is giving me a null value below is my code path:-V\M\Plugin; class GetAllRates{ protected $_logger; protected $cart; private $...
user avatar
  • 1,664
1 vote
1 answer
156 views

How to display out of stock products at the end of the catalog in MSI Magento 2.4.2

I want to display out of stock products at the end of the category page of Magento 2.4.2. i have msi implemented.
user avatar
0 votes
1 answer
77 views

Magento 2 Check if error then redirect to custom url

I am using create post plugin. But the issue with this is, I want to redirect it to a custom URL if an error occurred in createPost() default to execute the function. For example, if a customer with ...
user avatar
  • 21
0 votes
1 answer
15 views

How to make the product price as a specific amount

I want to make the price of all product to 100 in the cart. I have created a plugin and tried using it but I was not able to change the price value.
user avatar
0 votes
0 answers
36 views

Before plugin doesnt work

I'm trying to add a dash (-) in-store code in magento2. Magento by default doesn't allow it. Below is the function which does the validation. protected function _getValidationRulesBeforeSave() { $...
user avatar
  • 1,177
0 votes
1 answer
221 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 ...
user avatar
  • 2,717
0 votes
0 answers
28 views

Generate product URL in CMS page, Catalog Search page, Sitemap, Canonical URL with category path

I want to generate or print the product urls in CMS page, Catalog Search page, Sitemap, Canonical URL with category path. currently my product url in CMS page, catalog search page and in canonical ...
user avatar
0 votes
1 answer
108 views

How can I get customer data in a plugin class?

I'm trying to access logged in customer data in an "after" plugin. The plugin is working, but I need some logic based on a custom customer attribute. I try to do this but I get an error ...
user avatar
0 votes
0 answers
31 views

Magento 2 : Update billing address using around plugin while doing place order

Original method /** * Place Order * * @param mixed $result * * @return string * @throws CouldNotSaveException */ public function place_order($result, $location) { $paymentMethod = $result['...
user avatar
  • 367
0 votes
0 answers
44 views

Is there any way to change website (Sales Channel) stock on the fly (plugin or observer)

I have one website and three stocks, every stock is linked to one source, I also have a dropdown list which display those three sources as Stores (it is like Store Selector). What I want to do is ...
user avatar
  • 2,055
0 votes
0 answers
26 views

Class Interceptor error

I have developed a module that use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection but when I call the method i get this error: Error occurred when creating object: Oct\Oct\Helper\Search\...
user avatar
  • 529
0 votes
0 answers
17 views

Change compression level of PNG product images?

In Magento/Framework/Image/Adapter/Gd2.php there is this function: public function save($destination = null, $newName = null) { $fileName = $this->_prepareDestination($destination, $...
user avatar
0 votes
1 answer
88 views

How to make user register but not login in magento 2.4

I want to make user register and redirect to login page in Magento 2.4. User not automatic login. I have created a plugin for that and created a file ( app/code/Registration/Redirect/Plugin/Customer/...
user avatar
  • 526
0 votes
1 answer
46 views

There has been an error processing your request: "0":"Unable to serialize value. Error: Malformed UTF-8 characters, possibly incorrectly encoded"

I am attempting to set up my local environment for Magento. When I try to view the front end, I get the following error on the page: There has been an error processing your request Exception printing ...
user avatar
0 votes
1 answer
111 views

Magento 2.4 Preference on Block does not work

What i'm trying to do is to rewrite a core function of ( MagentoMagento\ConfigurableProduct\Block\Product\View\Type\Configurable ) The function is called getJsonConfig() public function getJsonConfig(...
user avatar

1
2 3 4 5
12