Questions tagged [event-observer]

Event/observer is used to work dynamically with Magento without altering the core code.

Filter by
Sorted by
Tagged with
-2
votes
2answers
25 views

I want to get product id after order is paced using observer [closed]

events.xml <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> <event name=&...
0
votes
1answer
11 views

How to detect the page handle in my observer?

I want to avoid the execution of my observer in case the page handle contains checkout or catalog, how could I do it?
0
votes
1answer
17 views

Only partial order object in `sales_order_invoice_pay` observer when subtotal is zero

I have an observer for the sales_order_invoice_pay event with the following code. public function execute(\Magento\Framework\Event\Observer $observer) { $order = $observer->getEvent()->...
0
votes
1answer
11 views

How do I know what data I can access via an observer?

I'm trying to use the sales_order_invoice_pay observer. I can see the dispatch in: /vendor/magento/module-sales/Model/Order/Invoice.php $this->_eventManager->dispatch('sales_order_invoice_pay', [...
2
votes
1answer
51 views
+50

Magento 2: What is the best way to observe cart change to modify cart item in magento 2?

I'm using Magento v2.3.4 and i want to modify the cart item, if there is an update on the cart (add to cart, update cart item, and remove cart item). Currently I'm using plugin for quote collectTotals(...
0
votes
1answer
13 views

layout_generate_blocks_after observer is not redirecting to checkout/cart page in Magento 2

I'm using the observer layout_generate_blocks_after to perform redirection to an empty cart on a condition but it is not redirecting. Any help would be appreciated. Here is the piece of code which i ...
0
votes
0answers
7 views

Get the 'password' Value from AJAX Login Magento2 in the event customer_login

I need to login to another website with the same credentials when the customer_login event fired but with this code public function execute(\Magento\Framework\Event\Observer $observer) { $...
0
votes
1answer
22 views

Magento 2: Product attribute is not get any value in observer

Here am using if condition to redirect if product attribute option value is !5431 but attribute is not echo any value here. <?php namespace Softadroit\Prescription\Observer; use Magento\Framework\...
0
votes
0answers
20 views

Magento 2 : Is there a event which fires before every controller begins execution?

The best event I could get was the good old controller_action_predispatch but it fires after the controller is done execution and before layout generation. Any other event that works in frontend area ...
0
votes
0answers
36 views

How to save custom attribute in quote_item using api / rest

I'm creating a module where I add a new field in the quote_item and order_item table (not necessary in the product). The columns were created, and when I look at the items in the cart, I fear the ...
0
votes
2answers
50 views

Magento 2: Redirect custom attribute option to cms page url in obsever

How to redirect if custom attribute option value != 5431 to cms page else redirect to module Controller (prescription/index). Till now both conditions redirecting to module Controller <?php ...
0
votes
1answer
20 views

Magento 2: How to redirect to different urls using if else conditon in Observer

This is my observer code: <?php namespace Softadroit\Prescription\Observer; use Magento\Framework\Event\ObserverInterface; use Psr\Log\LoggerInterface; class Orderplaceafter implements ...
0
votes
0answers
10 views

Magento 1 only one observer being overridden

I am trying to override two observers from the Zaius extension, but only one of them is being overridden. Here is what I have so far: config.xml: <config> <modules> ...
0
votes
0answers
25 views

Magento 2.4 - No route 404 page loading with product page issue

I redirecting 404 not found page to product page using controller_action_predispatch_cms_noroute_index event observer. Observer: $request = $observer->getData('request'); $request->initForward();...
0
votes
2answers
13 views

Magento 2: Remove account element only for certain store views?

After much fighting with my layouts to add a link to my customer account page in a way that matches the design I finally succeeded in making the link show up and link to an actual page that also ...
0
votes
0answers
19 views

Update Mini Cart After Free Product Add Magento 2

I made a module for free product like if Cart Subtotal is above $600 then a product programmatically add to cart, for this I made an event called checkout_cart_add_product_complete, so when I add ...
0
votes
0answers
23 views

Magento 2 How to update custom order attribute after save invoice

i am using this - di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:...
1
vote
0answers
47 views

Magento 2 which plugin can use for after invoice or shipment from admin

I am using this di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:...
1
vote
1answer
39 views

Error when getBlock('category.products.list') in Observer

public function __construct( Config $pageConfig, Category $categoryHelper, UrlInterface $urlBuilder ){ $this->pageConfig = $pageConfig; $this->...
0
votes
1answer
31 views

Uncaught Error: Using $this when not in object context

I am going through an older module created in PHP 5.x.x and we have just moved the website to the php 7.2.x so we suddenly got the error in a helper class Uncaught Error: Using $this when not in ...
0
votes
0answers
21 views

Product Qty update after order place Magento 1.9

I am doing it via observer but nothing is working. here is my code snippet: config.xml <checkout_onepage_controller_success_action> <observers> <qtyupdate> ...
0
votes
2answers
71 views

How check qty before add to cart in magento 2?

I need intercept the product qty before add in cart. I see the events list but don't find any observer to make this action. Any idea? Thanks.
1
vote
1answer
129 views

Magento 2 : Get a custom customer attribute to appear on the checkout success page

I've recently created a customer attribute for my Magento ver. 2.3.5-p1 instance using the following blog: https://www.blog.sashas.org/magento-2-1-3-how-to-make-customer-attribute-update.html The ...
0
votes
0answers
16 views

Magento 2 catalog_product_upsell Observer

I created an observer for catalog_product_upsell to add products from the same category, but I'd like to show bundle products first, if there are. So i check collection by a logger: $upsell = $...
0
votes
0answers
28 views

Magento 2 How to get order id and set custom order attribute after or before order placed

when using these events - 1 - sales_order_place_after 2 - sales_order_save_before 3 - sales_order_place_before Using these events I am able to set custom order attributes but unable to get order ID ...
0
votes
1answer
22 views

Product URL issue in Observer Magento 1.9

I have create an Observer function which is call after product save but having some issues with product url. Getting product like: $product = $observer->getEvent()->getProduct(); Getting ...
0
votes
1answer
24 views

Get data from orders with observers

I am with magento 2.3.4, and I want to capture the information: product order client I would also like to know how I can print the data on the console. I am using the observer when ordering ...
0
votes
0answers
14 views

Magento 2 why area code is showing wrong?

we placed order from magento frontend checkout when we check area code from this - $this->_checkState->getAreaCode() then we are getting area code is "webapi_rest" it must be frontend....
1
vote
1answer
26 views

How to get InvoiceId from sales_order_invoice_pay in magento 2

How to get invoiceId from sales_order_invoice_pay event. $invoice = $observer->getEvent()->getInvoice(); $invoice->getIncrementId(); Can't get with this code But with ...
1
vote
0answers
8 views

M2 | Is there any observer we can call with customer token generation API?

I want to perform custom operation by getting customer information when a customer token is generated using API. rest/V1/integration/customer/token Is there a way in magento I can get customer data ...
2
votes
0answers
27 views

Magento 2: event or plugin after filters applied and removed in category pages

I want to write customization on after filters are applied and filters are removed in category pages. I need any event or plugin while filter applied or filter removed in Magento 2.3.2.
1
vote
0answers
10 views

how to switch currency depending on the language code in $ _SERVER

I use a separate translation service, it makes a copy of my frontend and redirects to another domain. I am using language switcher from this service. since they are not related to magento stores I ...
2
votes
1answer
28 views

Using Observer stop execution of next function in Magento 2

I am using an observer on event sales_order_save_before to check for a condition and based on that condition I was to stop the save functionality. Currently I am using it on Submit Comment in Sales ...
1
vote
1answer
23 views

How to assign a product source from Event Observer

When a product is saved, I want to check if the product has an inventory source set, and if not, set one. The event name I'm observing is catalog_product_save_after. This is the Observer code: class ...
0
votes
2answers
31 views

How to use type for event in xml?

I want to call my observer after the adminhtml_cache_refresh_type event and specifically after full_page This method does not work, is there a way to do this in observer? <event name="...
0
votes
1answer
32 views

Observer function auto call twice in magento 1.9

I have created one function in Observer and set it called on product save after via config.xml file events section. When I press "save & edit continue", this function log all the ...
1
vote
0answers
22 views

Magento 2 : Activation/Deactivation and uninstallation module event

I am writing an extension for Magento 2. When my extension is activated, I want to send a request to my backend to register a merchant. And when the merchant deletes my extension, I also send a DELETE ...
1
vote
1answer
30 views

cannot get session value in different events

I'm using two different events controller pre dispatch and controller post dispatch.I have set customvalue using catalogsession in predispatch event and try to get the value in post dispatch event....
1
vote
1answer
45 views

Magento 2 - What is the Event name after customer edit address only

I need to use events 2 places 1 - When customer verified email <event name="controller_action_predispatch_customer_account_confirm"> <observer name="...
2
votes
1answer
34 views

How to clean cloudways Varnish cache after cleaning statics on magento 2 side

I wrote a class that works if I call it through pure php. It looks something like this class CloudwaysAPIClient { const API_URL = "https://api.cloudways.com/api/v1"; ... public ...
1
vote
1answer
27 views

Fire event observer when product is enabled

I want to fire event observer when products are enabled from admin, I can not find any event for this please help on this. I want to do below things Once the product is enabled or disabled need to ...
1
vote
1answer
25 views

observer to fire on system admin config display

In my plugin I'm trying to create an event observer that should fire when I display my plugin system configuration page. At first I created a new db table f24_staging by \Vendor\MyApp\Setup\...
0
votes
0answers
11 views

How to update the cart from observer

I have some conditions on my store based on the customer billing address. When someone saves their address, I would like to update the items in their cart (and minicart) to ensure correct prices are ...
0
votes
1answer
21 views

I need to set an activity if the customer is created or updated but it is not working in magento 2.3

events.xml (path : app/code/vendor/module/etc/frontend) <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation=&...
0
votes
1answer
20 views

Detect if payment has been placed in sales_order_save_after observer in Magento 2?

I have a custom extension that uses sales_order_save_after basically i want to create an invoice after the customer put a payment data , the problem is the order seems not been created at so i got an ...
1
vote
1answer
51 views

Magento2: magento rest api not triggering my custom plugin and observer?

I have created an observer "checkout_cart_save_before" and plugin Addproduct. It is working perfectly for the website but not triggering for API while hitting on the postman. Any suggestions ...
1
vote
2answers
30 views

How to get all items of product purchased in Magento 2?

I would get information on all items of product purchased. I proceeded by this way but I can not have any information on all items of product purchased : <?php namespace MyTestSpace\...
0
votes
0answers
9 views

Magento 2 : Redirect customer to login page on email change

i want to redirect the customer to the login page when email id is changed from edit form ,i did below code Issues : 1: I am not getting redirected to login page, i can see message **Please Login now*...
0
votes
1answer
65 views

Magento 2 : event observer before customer edit form save

I want to fire event observer before customer account edit details are saved, i am unable to find event observer for it. Is there any observer like customer_account_edited_before.
0
votes
0answers
23 views

magento 2 observer on customer email change

I want to fire observer when customer email is changed, i could not find any event for it. please help with same what i want to is below 1: fire observer on customer update customer details 2: check ...

1
2 3 4 5
40