The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [event-observer]

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

Filter by
Sorted by
Tagged with
24
votes
1answer
48k 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) { $...
94
votes
15answers
23k 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?
18
votes
3answers
11k 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 ...
9
votes
4answers
2k 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; ...
18
votes
2answers
12k 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 ...
0
votes
2answers
110 views

Observer Mage::throwException error - status 503 error

I just want to restrict some of the category of products to purchase with other category products, Workout : If customer click add to cart using observer compare current add-to-cart product ...
6
votes
1answer
15k views

How to bind an action after customer login success using Magento?

I'm using Magento 1.4.1.1. After logout success, customer is rooted to "logout.phtml" first and "home page" later. Is there anyway I could make Magento run couple of "php" codes after "login" ...
27
votes
2answers
6k 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 ...
7
votes
5answers
11k 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 ...
6
votes
1answer
8k 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 ...
15
votes
2answers
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(...
10
votes
2answers
12k 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,...
31
votes
4answers
16k 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 ...
1
vote
1answer
353 views

Product edit form issue in admin panel magento2

Here is my etc/adminhtml/events.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events....
0
votes
2answers
80 views

Restrict products to purchase using Observer not trigger

Condition: I have restricted category of products [category id = 680, 894, 895], this category of products should be purchase alone, not mixed with other products. Workout: Case 1: If cart had other ...
7
votes
1answer
2k views

magento 2 event cataloginventory_stock_item_save_after

I need to detect whenever the inventory level of a product changes. As there is cataloginventory_stock_item_save_after in magento 1.x wanto to implemet same in magento 2.1 <event name="...
45
votes
2answers
5k 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 ...
13
votes
3answers
7k 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 ...
15
votes
5answers
36k 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->...
8
votes
4answers
8k views

How prevent a model data save using _save_before event

I have create a model which has its own database table. For a customization I need to trigger save_before event of this model. If one field value is not matched, then the data should not be saved. ...
11
votes
4answers
23k 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 ...
2
votes
4answers
7k views

customer_register_success not triggered after successful registration

I would like to send an sms on every successful registration. Below is my code. But I am not sure whether the method is triggered after successful registration. app\etc\modules\Php_Sms.xml <?...
4
votes
3answers
9k views

Magento 2: Get Customer data after login with observer

I need to detect in frontend section for my custom module if customer has just successfully logged in, and i need to run some function before it redirect to another page, is there any way to do this?
1
vote
0answers
853 views

Magento 2: Admin price changes are not refreshing minicart immediately till checkout

I have added 1 product with it's price in Cart. It's value is 100 USD. Now from backend I'm enabling Special Price & set it to 50 USD. How can I directly apply that price in Cart? I know we can ...
16
votes
5answers
12k 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)
10
votes
3answers
5k 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 ...
6
votes
2answers
5k 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\...
5
votes
2answers
4k 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.
4
votes
2answers
4k views

Magento 2: Add a mass action block item for a UI Component grid

I am trying to add a mass action item to the product grid mass action block using an observer. Here is what I am doing but it does not seem to be working, I feel like I am missing something app/code/...
5
votes
3answers
5k 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 = $...
5
votes
2answers
968 views

How to exclude products being added to cart based on products attributes?

How can i set a condition, if pre-ordered products are purchased, no other products can be added to cart? How can I set a condition like, if some of the "non-pre-order" products is in the cart, ...
1
vote
2answers
8k views

Return error message from observer Magento

I made a custom module for observer on customer save before event for admin-side My config file in local/Pavans/Profile/etc <adminhtml> <events> <...
6
votes
1answer
3k views

What is the event that will fire after cancelling the order in Magento 2

I am trying to do something customization from my custom module after an order has been cancelled (Frontend as well Backend). For this I have gone through cancelled Observer on the sales/etc/events....
2
votes
1answer
6k views

How do i get active filters in observer method?

i want to check the currently applied layered navigation filters using an observer. When specific filter values are selected an additional layout handle should be added which adds a static block to ...
3
votes
1answer
415 views

observer getting called more than once

i wrote below observer to add extra price to product price based on get paramter id of product <catalog_product_load_after> <observers> <setcustomprice> ...
1
vote
1answer
4k views

Magento 2 - sales_order_shipment_save_after

I need to call some API on ship item from magento but nothing is working. Following things I already tried: 1) Use event/observer: sales_order_shipment_save_after (As I thought It will work in ...
1
vote
1answer
1k views

Adding extra fields to newsletter_subscriber table not work

I try to add a type(extra field) to newsletter_subscriber table. Following is my approach to add the field. 1.Add new column to newsletter_subscriber table(types) 2.Add types check box to subscribe....
0
votes
2answers
3k views

Magento event for adding order comment

Can anyone please let me know if there is any magento event available for adding comment to a particular order? Let me know if question is not clear.
12
votes
2answers
2k 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 ...
8
votes
2answers
3k views

review_save_after event observer is not running correctly

I am using Magento 1.8 version. I have written an observer that has to run when admin save a product review with status "Approved". And i have created a ratings attribute for every product with ...
7
votes
4answers
11k views

Call action after “Save Config” was clicked in the admin

How can I call an action of my controller in a custom module after "Save Config" was clicked in System --> Configuration --> Catalog? (image) Settings of my module are inside that section, and I need ...
12
votes
2answers
14k 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.
5
votes
1answer
4k views

magento 2 run function on every page

I have a function that retrieves a visiting user's country name by doing an ip lookup. I currently have this function running through the execute method in my module's controller. The problem is ...
7
votes
3answers
3k views

Unregister event observer programatically

Does anyone know if it's possible to unregister an event observer programatically? I have an observer on newsletter_subscribe_save_after that updates a custom attribute in the customer model but when ...
6
votes
3answers
5k views

Add to wishlist without customer login

I am developing an extension where is a requirement of add to wishlist without logging into customer account. can anyone help me out in this? what i think two things can be done here - 1- we can ...
6
votes
5answers
2k views

Magento 2: How to implement First Order Discount?

I am planning to give the discount to the customers for their first order purchase. After shipment selection, I want to show the discount in the order summary(discount is only for the first order). ...
11
votes
3answers
11k 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 ...
11
votes
2answers
828 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 ...
10
votes
1answer
832 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 ...
6
votes
2answers
7k views

Get post data, in Checkout success observer

I have added custom field on checkout page. I want to get all the post data, in Checkout success observer, Here is my observer code <?php /** Author : Disha **/ namespace Neo\OrderComment\...