Questions tagged [event-observer]

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

Filter by
Sorted by
Tagged with
96 votes
15 answers
24k views

Where can I find a complete list of Magento events?

I know that Magento has a hook-like system called events. Does anyone have a complete list or a script which can be used to determine which events can be called?
benmarks's user avatar
  • 16.7k
48 votes
2 answers
6k views

Magento Event Observers: Singleton versus Model

So Magento offers 2 ways of declaring an observer. Singleton and Model (new instance) by specifying the <type> tag in Magento 1.x and by specifying the shared attribute in Magento 2. Magento 1 ...
Marius's user avatar
  • 198k
34 votes
2 answers
73k views

Magento 1 - How to check whether user has logged in or not in magento?

I am doing mobile apps and I would like to know how to check whether user is already logged in or not. Is there any observer event to track? If it is detected that the account is logged in, the user ...
May18's user avatar
  • 581
32 votes
4 answers
20k views

Modify tax rate on cart quote items and recalculate

I have a category of products which (legally) need to have their tax rate changed when you are ordering more than a certain quantity. I have extended the various tax models to get this working when ...
McNab's user avatar
  • 1,078
30 votes
3 answers
14k views

Magento 2: Plugin vs Observer

In Magento 2, what are the pros and cons of using a plugin vs an observer to achieve something? I understand that observers are subscribed to events whereas plugins can jump in before and/or after a ...
scrowler's user avatar
  • 2,014
28 votes
4 answers
39k views

Confusion with order id, order increment id and I am not getting order id as 20001201

I am bit confused with order id and order increment id, So can any one help me to understand the difference between these two? I have an observer for sales_order_place_after where I store sales ...
Charlie's user avatar
  • 3,126
27 votes
4 answers
4k views

Returning $this after observer

I see some conflicting information on the internet and in 3rd party modules alike - is it a requirement or best practice to return $this at the end of an observer method? E.g.: ...
philwinkle's user avatar
  • 35.8k
26 votes
1 answer
53k views

How to create an new observer on the event catalog_product_save_before

I want auto generation of meta description for my products by create an new observer on the event catalog_product_save_before with this code : public function autoMetaDescription($observer) { $...
Dinesh's user avatar
  • 809
25 votes
12 answers
122k views

How to get product image and URL in Magento 2?

This is my observer: public function execute(\Magento\Framework\Event\Observer $observer) { $orderIds = $observer->getEvent()->getOrderIds(); $order = $this->...
Ramkishan Suthar's user avatar
19 votes
2 answers
14k views

Detect inventory change

I need to detect whenever the inventory level of a product changes. I've had some success using the cataloginventory_stock_item_save_after event which is triggered when inventory is changed in the ...
gregdev's user avatar
  • 303
19 votes
3 answers
25k views

Redirect from Observer [duplicate]

I am creating a module that needs to do a check right before payment is made. If the check fails, it needs to forward the user to the cart with an error. I have an observer and have verified ...
Jamersan's user avatar
  • 321
18 votes
3 answers
12k views

Creating Custom Option on Product Save

I'm working on creating a custom option for my products automatically any time a product is created. What I've got so far is an observer that fires on the catalog_product_save_before event and runs ...
Jason Neumann's user avatar
17 votes
4 answers
2k views

Is there an event or plugin spot for when cart rule is no longer valid?

Is there an event or place I can plugin for when a shopping cart price rule is no longer valid (such as when it expires or if you change the quantity of other products where it no longer applies)? I ...
Scruffy Paws's user avatar
16 votes
5 answers
17k views

Magento 2 events list

Is there any complete list of events in Magento 2? I'm looking for something like Magento Events Cheat Sheet (1.9)
mbalparda's user avatar
  • 7,363
16 votes
2 answers
6k views

Difference between `sales_order_place_after` and `sales_order_save_after`?

Magento 1 and Magento 2 both have the two event: sales_order_place_after sales_order_save_after. I have some confusion about them, what is the detailed differences between them? Which situation ...
Key Shang's user avatar
  • 3,385
16 votes
3 answers
7k views

How to get events/observers in magento 2

In Magento 1 I can get list of events/observers by debugging dispatchEvent() method from Mage.php like below. /** * Dispatch event * * Calls all observer callbacks registered for this ...
Bojjaiah's user avatar
  • 4,028
16 votes
1 answer
10k views

Why are my SOAP v2 WS-I calls so slow (7-10 sec. per product update)?

We're using the Magento SOAP v2 API with WS-I. The problem is, that the SOAP calls are extremly slow (7-10 seconds per product!). We're calling catalogProductUpdate without images. The shop itself ...
Anna Völkl's user avatar
  • 17.3k
15 votes
2 answers
9k views

Magento failing when trying to save product inside event observer on frontend?

I have a function that is tied to an event observer One of the requirements is that when it loops through the order item data, if a certain product attribute is empty it issues a request to get ...
Zxurian's user avatar
  • 161
15 votes
2 answers
11k views

Creating Custom option and prize to just added product to cart using observer

I want to add custom option to quoteitem using observer which observer checkoutCartProductAddAfter event and fires after product added to cart. public function checkoutCartProductAddAfter(...
Keyur Patel's user avatar
15 votes
2 answers
4k views

how to save image custom attribute in magento 2

I need to display few images of product in frontend based on condition: use for virtual mirror should be checked. <?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for ...
Siva Kumar Koduru's user avatar
14 votes
3 answers
21k views

Magento2 - How to stop a product from getting added to cart programmatically?

What I want to do is if my custom attribute is set in quote then i do not want any product to be added in cart. My custom attribute is being set correctly. To stop product from getting added to cart,...
Reena Parekh's user avatar
  • 1,917
14 votes
4 answers
28k views

Which observer to use after success order on Magento 2?

I am working on this Magento 2 extension and part of the features is to push information about the orders to an external application using web services. I need to push this information after an order ...
Eduardo's user avatar
  • 691
14 votes
4 answers
13k views

Magento 2 : Event Observer For Payment Method Selection

I am working on a custom extension where I need to call an observer when any payment method is select from the available payment method list on the frontend checkout page. Can anyone tell me which ...
Dhiren Vasoya's user avatar
14 votes
4 answers
3k views

When to dispatch events in a custom module?

This is a question regarding both Magento 1 and Magento 2. I understand that, as a good practice, 3rd party modules developers are encouraged to dispatch events in their custom module to make it ...
Raphael at Digital Pianism's user avatar
14 votes
2 answers
15k views

Changing the layout of the layered navigation

I have a layered navigation, and the customer wants to have <select/> fields instead of a long list of links. I thought about just changing the template with a observer if the name/id of the ...
Fabian Blechschmidt's user avatar
12 votes
9 answers
28k views

Magento2: redirection from Observer

We have already know that How to redirect from an Observer for magento 1.x version. but for magento 2,we does not know How to forcefully do redirection from an observer. I have done google ,but does ...
Amit Bera's user avatar
  • 77.2k
12 votes
2 answers
15k views

How to disable an event observer defined by default in Magento2 [duplicate]

I would like to disable an event observer attached to certain event in default magento. The Magento\Bundle\Observer\AppendUpsellProductsObserver observer is attached to the event ...
Atish Goswami's user avatar
12 votes
2 answers
1k views

What's the last event dispatched before content is sent to the browser?

I need to set or update a cookie, but I want to ensure that all (or as much as possible) of the request processing occurs before my cookie generation code runs. i.e. if the user logs in, I want to ...
Jim OHalloran's user avatar
12 votes
2 answers
15k views

How can i get customer data from observer after successful login?

I have made a custom module in which I have an observer file. I need to display all information about the logged in user.
user2656802's user avatar
11 votes
4 answers
24k views

Watching Add to Cart Event - quote item id is empty

I am trying to catch the event that fires once an item is added to the cart. I'm currently watching the following event: checkout_cart_product_add_after According to magento source this event is ...
Nuno Furtado's user avatar
11 votes
3 answers
3k views

How can I alter a string passed by an event?

In my observer function, I get a variable passed by the event like that: public function observerFunc(Varien_Event_Observer $observer) { $sth = $observer->getEvent()->getSth(); } If sth is ...
Simon's user avatar
  • 5,695
11 votes
1 answer
2k views

Remove observer from third party extension

I have installed a blog module onto my Magento 2 platform. This blog module has an observer which automatically adds a new menu item into the primary navigation. I wish to stop this. The events.xml ...
Angus's user avatar
  • 111
11 votes
1 answer
3k views

Magento 2: Observer add product to cart?

I've read some other post about adding products to cart, but nothing seems to fit. I've an observer for checkout_cart_update_items_before that adds another product in same qty if specific product is ...
sv3n's user avatar
  • 11.6k
10 votes
2 answers
11k views

what is the event in magento 2 when store configuration save?

what is the event that is triggered after the save config action is performed in magento 2 Stores - Configuration, and how to write a simple observer method after the save is done.
Dev's user avatar
  • 1,144
10 votes
3 answers
15k views

How to override observers in Magento 2?

I was trying to override execute function of Magento\CatalogUrlRewrite\Observer\ProductProcessUrlRewriteSavingObserver using preference in di.xml <preference for="Magento\CatalogUrlRewrite\...
amitshree's user avatar
  • 6,896
10 votes
3 answers
7k views

Event/Observer for customer password change?

I'm looking for a way to hook into the event of customers changing their passwords. So if someone changes the password in the customer frontend, I'd like to send an e-mail somewhere. I did consult ...
oschloebe's user avatar
  • 926
10 votes
3 answers
7k views

Magento 2 : Newsletter Subscription Event

Is there an event in Magento 2 for Newsletter Subscription from the Profile page? How do I find out when a user updates their newsletter subscription preference from this page?
Guruji's user avatar
  • 155
10 votes
2 answers
2k views

Magento event to calculate price when custom option text field changes

I am trying to create a product with two custom text fields: Length and Width. When the user types in both a length and width, the price needs to calculate via custom formula. I'm trying to find the ...
Clayton-a's user avatar
  • 101
9 votes
3 answers
1k views

Does interception in magento2 replace observers in magento1?

Is interception intended to be the preferred method when dealing with changing the behavior of an original method in Magento2 as observers was in magento1? https://wiki.magento.com/display/MAGE2DOC/...
Matoeil's user avatar
  • 607
9 votes
4 answers
4k views

Magento Observer Events - order of operations

I am attempting to inject functionality into the catalog_model_product_duplicate event. Part of this module will be to ensure that the stock status of the duplicated product is also duplicated; ...
philwinkle's user avatar
  • 35.8k
9 votes
7 answers
12k views

How to get order id using "sales_order_place_after" event

I have an event Observer for sales_order_place_after namespace Company\Ordertool\Observer; use Magento\Framework\Event\ObserverInterface; class OrderComplete implements ObserverInterface { /** ...
Battle Mage's user avatar
9 votes
3 answers
8k views

Magento 2 - sales_order_place_after not returning Order ID

I have created an event for sales_order_place_after event. This doesn't return Order Id. However, it returns Increment ID public function execute(Observer $observer) { $order = $...
Jancy Abraham's user avatar
9 votes
1 answer
19k views

What's the best event/way to listen for all order state changes in Magento 2?

I want to observe every order state change and react depending on the old and new status. What is the best way to accomplish this in Magento 2? It looks like there is the event ...
Jey DWork's user avatar
  • 1,101
9 votes
3 answers
2k views

Magento 2: Which extension mechanism to choose?

We can extend controller in two ways: using preference and using plugin. But I do not understand that, which one is good and advantages/disadvantages of preference vs plugin. <preference for="...
Anand Ontigeri's user avatar
9 votes
3 answers
13k views

Observing order state change

It seems there is no order state event by default, so how do you usually go about observing order state change? There are two possibilities I see: a) Overwrite the sales/order model to create your ...
mpaepper's user avatar
  • 4,700
9 votes
3 answers
6k views

Determine if customer is new in customer_save_after

I have events that I wish to execute when a customer registers or saves their details. For this, I am using two events: customer_register_success and customer_save_after. The problem I am having is ...
Matthew Haworth's user avatar
9 votes
1 answer
11k views

Add new total to grand total using observer in Magento?

I want to add some extra amount to Grand total in Magento. So in checkout page, order review section will look like this: This extra charges will depends on some conditions. My question is: How can I ...
Deepu Sasidharan's user avatar
8 votes
4 answers
13k views

sales_order_save_commit_after event triggered twice?

I registered an observer for the sales_order_save_commit_after event to be notified when a new order comes in. This works fine but the event is triggered two times in a row with the same order. My ...
PiTheNumber's user avatar
  • 3,214
8 votes
6 answers
16k views

Magento 2: Run reindexer programmatically

I am having a problem that I have costumer groups in our shop. When new customer is created and customer discount group is changed form BE. The customer cannot see their new prices. New customer sees ...
kilis's user avatar
  • 489
8 votes
2 answers
21k views

How to get RefererUrl in magento 2 observer?

How to get RefererUrl (source page url) in Observer file? Actually by using this; $this->_redirect->getRefererUrl(); I am getting Referer Url in magento 2 controller file.But in Observer file ...
shankar boss's user avatar
  • 1,439

1
2 3 4 5
44