Questions tagged [before-plugin]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
32 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() { $...
0
votes
0answers
18 views

magento 2.3 override phtml files which is called inside another phtml file and has no layout xml

I have a custom module that has replaced the product_list phtml with its own: <!-- file: catalog_category_view.xml --> <referenceBlock name="category.products.list" template="...
1
vote
1answer
98 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
1answer
57 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
0answers
33 views

Magento 2 how to create a Plugin for before Admin Product Grid loads?

I want to set a beforeProductGrid or something that exists, so I can enable or disable the Add Product Button. The only thing I have found so far is this Model Magento\Catalog\Block\Adminhtml\Product\...
0
votes
0answers
33 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
1answer
34 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
1answer
881 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
2answers
266 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
1answer
169 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
1answer
120 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
1answer
676 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
0answers
273 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\...
3
votes
1answer
2k 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
1answer
165 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
2answers
760 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
0answers
28 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
3answers
1k 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
1answer
1k 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
1answer
119 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
1answer
82 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
1answer
144 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
0answers
2k 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
573 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
0answers
497 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
1answer
2k 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
2answers
994 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
1answer
109 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. ...