Questions tagged [event-observer]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
22 views

Magento2 - Call to the empty Gift message object causes the observer class to fail

I'm trying to edit an associative array containing order info. This array for our backend application gets created under sales_order_place_after event once the order is placed .Everything works as ...
0
votes
0answers
25 views

Sending order create email when order is updated to certain status

I have created an custom email template which Mageplaza smtp sends when order is placed but I need it to be send went certain order status is set and so I have created an event which triggers on "...
1
vote
0answers
13 views

Define an event on select with event observer

My template is located in src/app/design/frontend/MySite/default/Magento_Checkout/templates/cart/item/default.phtml There is a select and in this select I'm adding an event. <select id="cart-<?...
0
votes
0answers
17 views

Magento2 - Error on checkout page while adding Configurable product to cart

I am using a custom module, where I want to redirect to checkout page once a product is adding to cart. For this I have created an observer controller_action_postdispatch_checkout_cart_index. For ...
1
vote
2answers
42 views

How to get customer from observer in Magento 2?

I need to send data to an external API when a customer (I mean a logged in customer) add a product to wishlist. I found the event: wishlist_add_product. $this->_eventManager->dispatch( '...
1
vote
1answer
27 views

Magento 2 get customer info after customer save event

I created a custom module that call a remote API service. I have to call this API on some events, like: customer create, customer edit, order create etc... For customer edit all works fine with: ...
0
votes
1answer
33 views

How to Go To previous Url with an Error from Observer in Magento 2

I am working on Magento 2 Extension i am trying to implement an event customer_save_before What i want to do is.. if user email is from a domain like abc.com it should go to Previous URL with an ...
0
votes
0answers
40 views

Magento 2: Rest API “Checkout Cart Product Add After” event is not working

I have faced issue in checkout_cart_product_add_after event using add to cart rest API. Same add to cart event is working in website. But it is not working in Add to cart rest API. Add to cart API ...
1
vote
0answers
13 views

What is the difference between getStoredData and getData?

I'm adding some custom logic in the admin when the customer is saved. I've created an observer on the customer_save_before event. I am using the following code to get the customer: /** @var \Magento\...
0
votes
1answer
26 views

Magento 1.9 - How to post data from predispatch event to controller action

I want to change the data that is processed in the checkout_onepage_saveBilling controller action. I am using an observer with the predispatch event to catch the POST data which is coming from the ...
0
votes
0answers
18 views

How to write an observer with verification of existing id

I have bundle products on which I display selects with some data <?php /* @var $block \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option\Select */ ?> <?php $_option = $block->...
0
votes
0answers
10 views

Magento 2 - changing store view from observer

I have an observer in my module (fired on controller_action_predispatch) which checks the current logged in customer billing country, and sets the store view accordingly. For example: $this->...
0
votes
0answers
23 views

How to observe event before saveShipping or saveBilling actions for address validation

Update: For my understanding (please correct me If I am wrong) the problem here is that the controller_action_predispatch_checkout_onepage_saveBilling gets dispatched and the following code is being ...
0
votes
1answer
25 views

Order items is empty when customer logged-in

I'm use following code to catch order information in this Observer : "sales_order_save_after" public function execute(\Magento\Framework\Event\Observer $observer){ $orderData = $observer->...
0
votes
1answer
30 views

sales_order_save_after event not fired when creating an invoice

I like the event to be fired when we create an invoice for an order, to get order status complete etc/adminhtml/events.xml <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
1
vote
5answers
171 views

Magento 1.9 - Anyone help me What is error in my Observer?

My Custom observer : app\etc\modules\Gta_FindPaymentGateway.xml <?xml version="1.0" encoding="UTF-8"?> <config> <modules> <Gta_FindPaymentGateway> <...
0
votes
0answers
7 views

checkout_submit_all_after is not fired when creating an invoice

I like to get the event when the order is changed to Complete, i tried checkout_submit_all_after event and sales_order_save_after but when i tried to create an invoice (to get completed order status) ...
0
votes
0answers
16 views

Limit Quantity For the Products With Specific Attribute Magento2

Trying to Limit all the products with having a specific attribute (Yes/No) and others will behave normal. I have used the event in my module my event.xml <event name="...
1
vote
2answers
33 views

Magento 2 - Observer after order not work

In Magento 2, I try to add an observer sales_order_place_after and it doesn't work. app/code/Vendor/Module/etc/event.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/...
0
votes
0answers
27 views

Magento 2 Custom Module - Load Subscriber Email in PHTML file after newsletter subscription

I am working on a custom module where we need to load the email address of a newsletter subscriber in a phtml file after they subscribe. Our Observer file is triggered on a subscription event and ...
0
votes
0answers
26 views

Programmatically stop a catalog search after it's been started in Magento 2.3.3

I'm using an observer on the event "controller_action_postdispatch_catalogsearch_result_index" to redirect the user to a landing page if their search query matches one of a number of specific phrases ...
0
votes
0answers
17 views

Magento 2 customer_register_success Event not getting triggered

Here am trying to trigger a Event on Customer Registration. but Observer is not getting triggered. Where am doing wrong. Can i get Help? Thank you in advance. This is the events.xml /app/code/...
1
vote
1answer
30 views

Magento 2 delete event get product skus using observer

I need to perform a operation when a product is deleted from admin. So I have created a observer using below code which is working fine. Vendor/Module/etc/adminhtml/events.xml <?xml version="1.0"?...
0
votes
0answers
30 views

Magento 1.9 Observer - PHP 7 mail function how to set multiple recipient mail id based on condition?

Following code for sending multiple recipient mail based on first digit of sku from order received, <?php class Gta_MerchantNotification_Model_Observer { public function merchantremainder($...
1
vote
1answer
19 views

Update Product Qty while product is being added to cart

I want to update qty to 2 when product is added to Cart. Basically I want that when a user ads a product to cart(qty is not visible for user), it is set to qty by default. I have created an observer ...
0
votes
1answer
29 views

Where is sales_model_service_quote_submit_before dispatched?

Where in the source does the event sales_model_service_quote_submit_before dispatch in Magento 2?
0
votes
1answer
23 views

How to store custom attribute after place order?

I am trying to store customer's reward point into sales_order table using event-observer. here is my events.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-...
0
votes
2answers
68 views

How to send Observer Response via mail?

My observer : <?php class Gta_MerchantNotification_Model_Observer { public function merchantremainder($Observer) { $order = $Observer->getEvent()->...
1
vote
0answers
19 views

Magento 2 get order qty items is null

I'm trying to get the total weight of the items in checkout_submit_all_after With this code: $orderItems = $order->getAllItems(); $weight = 0.0; $length = 0.0; $width =...
0
votes
1answer
27 views

I want to enable free shipping

I want to enable free shipping if some condition satisfies(programmatically). Which event should I use and how should my observer look like..? Kindly guide.
0
votes
0answers
10 views

Magento2: How to use product inventory(qty) in salesRules conditions

I want to apply the SalesRules based on product Qty on cart using event Observer. What is the best way to use this. I am using below events:- checkout_cart_product_add_after ...
0
votes
1answer
23 views

Magento 2 get dimensions of products in order event

I'm trying to get the dimensions(length,width and height) and weight of all products in an order. The event that I'm using is checkout_submit_all_after. In observer I have this code. $order = $...
0
votes
1answer
34 views

Get newsletter subscribed on customer save

I am trying to get the value of 'if newsletter subscribed' on customer save. I am using the event: customer_save_after_data_object for customer update and tried to get the subscription value by this ...
0
votes
1answer
15 views

Magento 2 order is shipped twice on sales_order_save_commit_after event

I'm trying to ship an order automatically everytime an order is placed, just with event sales_order_save_commit_after works, I tried sales_order_place_after and it throws me the error of "No such ...
1
vote
1answer
58 views

How to Remove Disable Product from Cart

I want to delete the Disable product completely, through Observer! Programatically Like if we have a Disable Product, We have to delete it. Product is disabled an event is triggered and remove that ...
0
votes
1answer
18 views

Magento 2 Can't ship order programmatically

I'm struggling trying to ship an order just after the order is created. In the event sales_order_place_after I'm executing the following code: use \Magento\Sales\Model\Order\Shipment\TrackFactory; ...
0
votes
1answer
27 views

Magento 2: force 404 based on category attribute

I have created a custom eav attribute for categeories (bool). If set to "no" a category page should present a 404 page. I have created an observer for the event layout_load_before in which I would ...
0
votes
1answer
24 views

Magento 2 how to create shipment in order event?

I'm trying to create the shipment of the order just after the order is created. I'm using the event sales_order_place_after. Here is my code , I'm running this method in execute(), and getting the ...
1
vote
1answer
110 views

Magento 2: How to add Additional Options in cart on “sales_quote_remove_item” event observer

I want to add additional options to the next product on the sales_quote_remove_item event while removing the first product from a cart. First Product, I have already added the first product to cart ...
1
vote
2answers
42 views

Change price at “checkout_cart_update_items_after”

I have some rules that change the price of product 'Z' if the quantity of products 'X' is 'Y' In the cart, how can I check the quantity of a product in the cart and change the price of that product ...
0
votes
1answer
29 views

This observer is not running at all

This is Observer. <?php namespace SimpleMagento\Custom\Observer; //use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; class Another implements ...
0
votes
0answers
28 views

Magento 1.9 - how to send custom email if order status pending more than 2 days?

I have event observer for getting order status, How can i send custom email if order status pending more than 2 days. eg: Company Logo:: Dear {{customer name}}, Your order pending more than 2 ...
2
votes
1answer
56 views

How to redirect to custom page after Customer Successfully register..!

I need to redirect to next controller after registering page.
1
vote
1answer
52 views

Need to redirect to given controller

I need to redirect to ('hello/Test/Customer') page but observer is not working. <?php namespace SimpleMagento\Custom\Observer; use Magento\Framework\Event\Observer; use Magento\Framework\Event\...
1
vote
0answers
19 views

Fire JS script in observer

How can i fire this JS with an observer every time a user is adding, updating or deleting a product from the cart ? <script type="text/javascript"> _paq.push(['addEcommerceItem', "{{...
1
vote
1answer
27 views

Magento:2.2.8 Save response in db under custom_column created in sales_order and quote tables

I am using Custom Shipping API where I am getting response from API. Here I want to save this response to my order and quote table, I used event checkout_onepage_controller_success_action Here's code ...
1
vote
0answers
18 views

Magento 2: Set Product final price using catalog_product_get_final_price Event

Using eventcatalog_product_get_final_price, setting the maximum price to be 100, if the price of a product is greater than 100 then it will set automatically to 100 and the product price is below 100 ...
0
votes
0answers
27 views

Magento 2 set custom variable to use in email template on all emails

I want to be able to add a custom variable through an event observer of some sort which enables me to output this variable in any given email template. I know I can make an event observer for example ...
0
votes
1answer
23 views

Saving order PDF when order is placed?

Magento 1.9.3.2 I am trying to save the order PDF right after an order is placed / saved. The event I am using is sales_order_place_after. This is working fine, except for the payment information. ...
1
vote
2answers
81 views

Update item custom quantity and salable quantity value after place order in Magento 2

I need to decrease purchased item saleable quantity with custom value (x* ordered_qty) after place order in Magento 2.Right now I'm using the following observer and class to update the quantity of ...

1 2 3 4 5 38