Questions tagged [before-plugin]
Denotes questions about Magento 2 BeforePlugins. For general questions use "plugin" tag.
33
questions
0
votes
2
answers
45
views
Before Plugin asks for the class argument
I am new to Magento and following a course, yet some things hold me back. I really want to learn it but my only duties are as a frontend developer. If you could guide me through this problem it would ...
0
votes
2
answers
466
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 ...
0
votes
0
answers
39
views
Plugin Class does not exists
I am creating plugin to alter API response in M2.4.3. I am trying to alter this functionality via plugin
Magento\Framework\Webapi\Rest\Response and function prepareResponse
My di.xml file is:
<?xml ...
2
votes
2
answers
915
views
Magento2 - some doubts using a before plugin
We want to add some logic when Magento saves shipping information during checkout, so we have tried using a before plugin for saveAddressInformation method
This would be method definition
/**
* Save ...
0
votes
2
answers
692
views
How to change the parameter being sent using a Before Plugin?
I have a before Plugin that runs when a customer data is updated thru the admin. When "save customer" is clicked I need to update the values of some of the fields (like customerID) the form ...
1
vote
2
answers
211
views
Observer that runs when an order is attempted to be created in the Admin
I need to create an observer or plugin or something else that will run when an order is attempted to be created through the admin. I added a custom attribute for customers (offline/online). If the ...
0
votes
1
answer
292
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&...
0
votes
0
answers
159
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()
{
$...
1
vote
1
answer
396
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 ...
3
votes
1
answer
793
views
Magento2 Append a css class to a product detail page if a special parameter is in the URL
Here's what I'm trying to achieve.
When a product page URL has a parameter added to it like so: https://example.com/This-THI08.html?specialview=1
I'm trying to append a “specialview” class to the ...
0
votes
0
answers
231
views
Magento2 error message not showing in admin
I'm validating max sale qty when admin create order, I want to throw the error, it's redirecting back to order index page but error message not showing there? what's wrong here?
<?php
...
0
votes
1
answer
84
views
Plugin beforeGetUrl - not being used? (solved, facepalm)
I have grouped products "containing" simple products. I have had to make the simple products visible but while I am ok for them to appear in certain lists, I want the link to go to the parent page not ...
0
votes
1
answer
2k
views
Magento 2: Get the qty of products before added to cart
I'm trying to get the qty of products in a plugin with a method called beforeAddProduct, with this method I can manipulate things before being added to cart.
I need to check that the qty added to ...
0
votes
2
answers
701
views
Magento 2 plugins (interceptor) beforeCancel() making the cancel order bug
I have created a plugin which intercept the cancel function from the interface Magento\Sales\Api\OrderManagementInterface, the plugin intercept before the cancel function is called.
My problem is ...
1
vote
1
answer
446
views
Magento 2 how to restrict add wish list a product
I would like to stop adding products to the wishlist based on the product attribute how to do that? I would like to use the plugin concept instead of overriding the entire controller file.
Magento\...
1
vote
1
answer
547
views
Magento 2.2.2 Plugin how to add custom field in request api
I've create a plugin to listen to api POST /V1/order/:orderId/refund
and I would like to receive custom field. I've added a field for testing like: name:['test']
Body E.G:
{
"items": [
...
2
votes
1
answer
1k
views
Plugin intercept before place order for PayPal method on Magento2
In my Magento2 instance, I created a Plugin interceptor for run custom validation before process the payment. Works for all payment methods but PayPal Express or PayPal Standard.
di.xml
<config ...
1
vote
0
answers
659
views
Magento 2.2.2 order refund REST API Before Plugin get item order to refund
Vendor\Module\Plugin\Order\Plugin.php:
namespace Vendor\Module\Plugin\Order;
class Refund
{
/**
* Create refund for invoice
*
* @param int $invoiceId
* @param \Magento\Sales\...
4
votes
1
answer
3k
views
Magento 2 how to use elasticsearch for custom indexer? Custom sort stops working after enabling elasticsearch
I am a magento newbie and trying to implementing a custom sort on product listing page with the help of this:
https://magento.stackexchange.com/a/230983/84727
On top of the solution i have built a ...
0
votes
1
answer
318
views
Magento 2.3 customer beforeAuthenticate plugin not working
I am facing allowed memory size of bytes exhausted when ever trying to login customer in magento 2.3.2
I have used beforeAuthenticate plugin to do some functionality after sometime customer can not ...
2
votes
2
answers
2k
views
Throwing exception based on condition in before plugin
I'm creating a before plugin for the class \Magento\Customer\Controller\Account\EditPost. In the execute method I want to throw an Exception based on certain condition but the plugin is showing output ...
0
votes
0
answers
38
views
Magento 2 system config Concatenate data to existing field with plugin beforeSave or aroundSave
I have a drop down field containing fruits where I would like to concatenate some data e.G:
Using a Plugin save the data like so:
Bananas are high in potassium Where are high in potassium is the ...
1
vote
4
answers
3k
views
Order beforeSave plugin throws TypeError
I've built a plugin that catches the order beforeSave event in order to add some extra data to the an order attribute. The problem is that when this plugin fires it causes an error:
Uncaught ...
5
votes
2
answers
3k
views
Magento 2 :How to change or update request data using beforeExecute plugin?
i just want to change some request params by using beforeExecute plugin so can i do same.... ?
etc/di.xml
**
<type name="Magento\Customer\Controller\Account\CreatePassword">
<plugin ...
2
votes
1
answer
343
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?
2
votes
1
answer
316
views
get Coupon Code in beforePlaceOrder
Hello I want to get the coupon code in a plugin. My code is:
private $logger;
private $checkoutSession;
public function __construct(
\Psr\Log\LoggerInterface $logger,
\Magento\Checkout\...
2
votes
1
answer
270
views
how to save product name dynamically
for example i have 3 product attributes color ,size ,location.
i do not want to enter product name instead of it should save combination of color,size,location.
product name. 'red color small in new ...
0
votes
0
answers
4k
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
1
answer
1k
views
Observer or plugin use before the invoice creation
I have create custom attribute("current_seller_id") in sales_invoice_item and now want to save some value in this column how can i do this.
Actually i already save the value in sale_order_item table ...
1
vote
0
answers
979
views
Magento 2:"TypeError: Argument 1 passed to Test\HelloMagento\Plugin\ExamplePlugin::beforeSetTitle()
di.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<type ...
4
votes
1
answer
3k
views
On what basis we need to pass the plugin parameters?how we know what should be pass?what's logic behind it?
My requirement is here:-
I have a Game booking requirement in Magento 2, just like online movie booking(e.g- booking movie from Bookmyshow, Paytm etc). there is fix number of tickets in each slot ...
1
vote
2
answers
1k
views
Plugin Before Onepage Dispatch
I have the following plugin:
<?php
namespace Company\Module\Plugin;
class DisableLoginCheckout
{
/**
* @var \Magento\Customer\Model\Session
*/
protected $customerSession;
/*...
0
votes
1
answer
229
views
Before plugin for Submit query method
I am trying to create before plugin for SubmitQuote method of Magento\Quote\Model\QuoteManagement but plugin is not hitting.
Its a api req so i have declared the plugin in /etc/webapi_rest/di.xml.
...