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
0answers
7 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 ...
0
votes
1answer
10 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 ...
0
votes
0answers
17 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['...
0
votes
0answers
7 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 ...
0
votes
0answers
20 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\...
0
votes
0answers
8 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, $...
0
votes
1answer
23 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/...
0
votes
1answer
15 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 ...
0
votes
1answer
25 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(...
0
votes
1answer
31 views

Redirect to login page on specific store

I would like to redirect the customer from any page of the store to the login page if he isn't already logged in. I guess I need to make a plugin or an observer on some dispatch or forward method, but ...
0
votes
0answers
23 views

how to append url params by default forcefully in magento2

I want to add current customer session custom field to the every category url. lets say if user typed in the browser http://test.html , this should forcefully change to http://test.html?...
0
votes
1answer
29 views

Access array in before plugin to push data to it?

This is the original function I'm trying to write a plugin for: public function execute() { $data = $this->getRequest()->getParams(); .... } $data is an array. In my plugin I want to ...
0
votes
0answers
12 views

Magento2 obeserver or plugin before show the product

Maybe I do not see the forest for the trees, but I failed to find the following entry point: I need an event or function for a plugin, where I can add some data to a product. This data is relevant ...
0
votes
1answer
79 views

Create extension attribute to inventory source

I have a requirement to add the custom attribute (delivery_time) to each inventory source. my-vendor/module/etc/di.xml <?xml version="1.0" ?> <config xmlns:xsi="http://www.w3....
0
votes
1answer
33 views

Magento 2.3.4 UpdateItemsQty controller as well as plugin has wrong store

Purpose: Restrict cart item quantity update when total products are more than 10. So I have created around plugin for UpdateItemQty controller which check total quantities and return error when items ...
2
votes
1answer
115 views

What is final methods in Magento2?

When I read the limitation of Plugin in Magento2, the official devdocs mentions that, Plugins can not be used on following: Final methods Final classes Non-public methods Class methods (such as ...
0
votes
1answer
32 views

Magento 2 cannot Disable 3rd party plugin

Im trying to disable Amasty\Gdpr\Block\AccountLinkPlugin from my vendor folder. Amasty frontend/di.xml <type name="Magento\Customer\Block\Account\Navigation"> <plugin name="...
0
votes
0answers
23 views

I want to add qty filter same as price filter in layered Navigation in Magento 2

In this i want to develop functionality in which qty filter is added and in that range is displayed in layered navigation as price filter. qty range as below: 1 - 50, 50 - 100, 100 - 150, ... so can ...
0
votes
1answer
23 views

Magento 2 preference not working for Magento\Customer\Model\Metadata\Form\File

I want to create preference for this file Magento\Customer\Model\Metadata\Form\File but its not working so please give some solution for this problem how to solve it di.xml code
0
votes
1answer
78 views

How to add country code dynamically in telephone field on Checkout in Magento 2

I want to develop custom module that is used for adding country code field before telephone field on checkout page in magento 2.3.4.
0
votes
0answers
21 views

Overriding countries error when submitting order

I have created a plugin to override country options so that when you are in frontend it will allow the countries you have set in the configuration. And when you are in adminhtml/backend it will allow ...
0
votes
1answer
18 views

Display differet price on frontend

I want to display different price on the frontend. I just want to display it don't want to show in add it cart. I have created a product with zero price and I want to show 5$ price for that item. I ...
0
votes
0answers
17 views

Unable to create new service: ChromeDriverService error in MFTF Test for custom Plugins

I'm getting this error message while Running MFTF test commands in terminal
0
votes
2answers
27 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) { ...
0
votes
1answer
141 views

Magento 2.4.1 Move Out of Stock In last Of Category Listing

I want to move out of stock product in last of the category listing, itried below code but same seems not working. app/code/Meetanshi/StockQuantity/etc/module.xml <?xml version="1.0"?> ...
0
votes
2answers
60 views

Magento2 Addtocart before plugin not working

I have created before plugin for Add to cart functionality to check if product's custom attribute called My Tshirt(which is text field type) value "Jack" or "Jill". Plugin work ...
0
votes
2answers
32 views

Inject class into plugin

I created an plugin for afterGetProductPriceHtml() and it works so far. My di.xml: <?xml version="1.0"?> <config> <type name="Magento\Catalog\Block\Product\...
0
votes
0answers
71 views

Magento 2 prevent function from executing using plugins

There is a third party module which contain the RecurringData.php file. That class has install function which runs $this->testimonial->update(); function. I want to stop the execution of that ...
0
votes
1answer
33 views

Add additional information to product list item in widget

I was able to add some additional information to the products in the category and the search-result page with a plugin. Unfortunately it doesn't work for the widgets (product list widgets, related ...
0
votes
1answer
42 views

Magento 2: Class instance

When i printed this print_r(get_class($this->getOrder())); I got this class name Magento\Sales\Model\Order\Interceptor What does this actually mean ? Where is this "Magento\Sales\Model\Order\...
0
votes
2answers
29 views

Magento 2 : Code Explanation for plugin

I have override a template file Magento_Payment::info/default.phtml using following method this template is declared only in /Magento2/vendor/magento/module-payment/Block/Info.php file. The below ...
0
votes
1answer
25 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, $...
0
votes
1answer
18 views

How to load Data From Database via Ajax Call with Resource Model on Click?

Here is my Ajax Call. I call it inside click() function with jQuery. var customurl = gpImageTagLoadUrl + '?isAjax=true'; $.ajax({ url: ...
0
votes
1answer
29 views

How can I replace the final price with a string instead of a number?

I have some products where the company is still trying to figure out the price. Those products are currently set to 0. I was the words "Call for pricing" to show up if a price is 0. I wrote ...
0
votes
1answer
52 views

Override a model not working Magento 2

I tried to override a model in Magento\Quote\Model\Cart\Data\CartItem but I cannot override it. here is my di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/...
0
votes
0answers
17 views

Integrate Venia PWA Studio components into existing React app

I have a running React application based on create-react-app and I want to use some components from Venia such as Gallery, Checkout,... I tried to add Venia's webpack plugins into my existing app's ...
0
votes
1answer
21 views

Get extension_attributes in Plugin

In my API response (all orders) I get this extension_attributes "extension_attributes": { "my_attributes": { "order_id": null, "company_id": ...
0
votes
1answer
45 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 ...
3
votes
1answer
42 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
23 views

magento 2 hide out of stock products except when a specific attribute equals yes

I would like to hide out of stock products generally so I've added the option in the store configuration settings. However there are certain products that will be restocked soon. I'd like to keep ...
0
votes
0answers
40 views

How to override getList in orders API endpoint?

I need to implement my own logic in the API endpoint which is responsible for getting all pending orders (/rest/V1/orders?searchCriteria[filter_groups][0]...). I'm trying to do something like if(...) {...
1
vote
1answer
29 views

How to change model data via plugin

How to make a plugin for a model and turn one of its fields into a different value. For example, in the documentation, they make an after plugin for the model and return a different value. public ...
2
votes
3answers
105 views

Custom plugin: problem with full page cache and customer session

A client uses the FME Restrict Customer Group module to give customers that are logged in a selection of products based on a customer group. He wants to give customers the option to toggle this ...
1
vote
0answers
16 views

Magento 2 Translations not working on plugins

I have a translation file in app/design/frontend/vendor/theme/i18n/en_US.csv "sample_trans","Sample Trans" my problem is when i try to call it in a plugin via __('sample_trans'). ...
0
votes
1answer
23 views

Fatal error when replacing fuction output with a string using plugin

I'm, learning magento development and trying to create a custom module in Magento 2.3.6 with page at localhost/magento236/lesson3/Page/view The template file at Lesson3/Module/view/frontend/templates/...
0
votes
0answers
33 views

Magento 2 check customer is new on Around plugin on Create New account

How can i check if customer is new in magento 2 using around plugin for Create account action ? I am trying to check if customer is new then i will send a track event to segment. Let me know your ...
0
votes
0answers
15 views

How to log data about the order and its backtrace by saving

My orders are automatically closed, I want to find the reason. I wrote a plugin that saves the save order data, but it doesn't work, tell me why <type name="Magento\Sales\Model\Order"> ...
0
votes
1answer
13 views

Custom slide show

I have development custome slideshow. Backend it work normally insert . update delete and templates of this slide . How can I show this slide in home page
1
vote
0answers
13 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 ...
0
votes
0answers
46 views

Magento 2: Override Magento Framework class Not working

I want to override this class function in Magento 2 \Magento\Framework\HTTP\PhpEnvironment\Request::getServer() etc/module.xml <module name="Test_Override" setup_version="1.0.0"&...

1
2 3 4 5
12