Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [event-observer]

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

0
votes
2answers
25 views

Magento 2 origData null in customer_save_before

I have created an observer on the customer_save_before event. Surprisingly $observer->getEvent()->getCustomer()->getOrigData() is null. Is my expectation wrong? This is also happening for ...
0
votes
0answers
3 views

Magento 1.Logout customer after cart mergen when login

We have the following code which fires when the event sales_quote_merge_before is fired. So a customer adds 1 product to cart, then moves to cart and sees the 1 product. They then click a button [...
0
votes
2answers
32 views

add block in observer magento 1.9

I need to show labels(BACK ON STOCK) on product when they back to stock, for this I have added a observer <global> <events> <catalog_product_save_commit_after> ...
1
vote
1answer
46 views

Magento2: How can call observer function in controller file?

I have created a custom observer below: Observer file public function abc($order,$itemIds) { } Controller file public function aaa($order,$itemIds) { here we want to call abc($order,$itemIds);...
0
votes
0answers
21 views

How to add free product if subtotal is greater than $100 in magento 2.3?

I am very new to magento 2.3 learning. If subtotal of customer product purchase is equal or greater than $100, the free product should be added to their cart when checkout(Not show this product in ...
1
vote
4answers
35 views

how i can get order id and customer name in oberserver magento 2

I have used event <event name="checkout_onepage_controller_success_action"> when I use this code I am getting null $order $order = $observer->getEvent()->getOrder(); // im ...
0
votes
2answers
20 views

Can Magento really handle asynchronous execution of events?

The Swiftotter Magento developer Study guide states concerning Observers: Event data should be able to be stored and then run in a queue at a later time. Is this correct? Do I really have to ...
0
votes
1answer
27 views

Set the if condition to true in PHPUnit test case

I have an if condition inside an observer as follows public function execute(Observer $observer) { if ($observer->getData('status') == Status::REQUIRED) { //implementation ...
0
votes
0answers
20 views

Which Event File on sales_bestsellers_aggregated_daily Table

Which Event is Fire or which method use when sales_bestsellers_aggregated_daily, 'monthly', yearly when best sale product insert in these tables? I want to save the value in custom_attribut(...
0
votes
0answers
18 views

Get number of pages in Oberver Magento 2

I have an Observer and I must get the number of pages (I need to know if there is > 1 page) in it. I tried on both collection and pager but no success : public function __construct( \Magento\...
1
vote
0answers
15 views

checkout_cart_product_add_after fired only once for grouped product

I m observeing checkout_cart_product_add_after event to modify quote item. But it seems it fired only once no matter how many qty or item i have added from detail page. My goal is to change each ...
1
vote
0answers
20 views

How to debug checkout_cart_product_add_after event on exit

I am trying to exit point on observer for checkout_cart_product_add_after event. But it always refresh after item added to cart. Any way to print data when debug this event and not refresh the page. ...
0
votes
2answers
34 views

Custom price in cart not working in Magento 2.3.1 observer

I am developing a magento site for furniture sale. I have some grouped products. If a customer add 1 piece of any product of the group to cart, the special price will be added to cart. If the ...
0
votes
0answers
19 views

how to i set cart subtotal price through program in magento 2 observer

i created observer <event name="sales_quote_add_item"> <observer name="webkul_mpquote_sales_quote_add_item" instance="Webkul\Mpquotesystem\Observer\SalesQuoteAddItem" /> </...
2
votes
1answer
10 views

Get order object inside email_order_set_template_vars_before event observer

I have observer for email_order_set_template_vars_before where i am setting some email template variable to use in order confirmation email. Now i want to find which products customer has ordered in ...
1
vote
2answers
22 views

Cron Failure - Mage_Core_Exception

I get this from the error log all the time. Cron Failure catalog_product alert: ---EXCEPTION--- exception 'Mage_Core_Exception' with message 'Invalid callback: Model for productalert/observer:...
0
votes
0answers
13 views

Not able to set cookie in observer

I am trying to set a cookie on the observer "catalog_controller_category_init_after" but it does not create the cookie but when I do exit after set cookie it will create cookie after I remove exit ...
4
votes
2answers
108 views

Magento 2 : We need to save product two time After generating Custom Option programmatically?

I have work on Custom Module. In Our Module I had use <event name="catalog_product_save_after"> <observer name="add_custom_option" instance="Namespace\Modulename\Observer\...
0
votes
0answers
22 views

I need to add payment method for customer in customer_register_success event, Magento2

I need to add a default payment method for customers, is it possible to do it in time this event customer_register_success ? I added a drop-down list in the registration form and show active payment ...
4
votes
3answers
185 views

Using the same observer class multiple times

I have a piece of custom code that should be executed on different events but the code does not depend on anything the events send to the observer. It's basically a dumb code like: class MyObserver ...
0
votes
0answers
21 views

Send an email upon order status change

I'm trying to find a way to programtically send out an email, that doesn't depend on some front-end or admin behavior. Ideally, this email would be sent when the order status is changed to 'processing'...
1
vote
1answer
29 views

Difference between core_abstract_delete_after and core_abstract_delete_commit_after events in magento 2

Can anyone please explain to me what is the use of core_abstract_delete_after and core_abstract_delete_commit_after events in magento 2. For your information, it is declared in (Magento\Framework\...
0
votes
0answers
29 views

Magento 2 cookie not set when full cache enable

I have created one helper file that get, set and delete cookie. This helper file I called in observer to set cookie. The helper file called but cookie not set when full cache enabled. <?php ...
1
vote
1answer
44 views

Creating custom event observer for after sale

I'm attempting to create a custom observer that will trigger after a successful purchase has been made. I assume that sales_order_save_after is the correct event to use. What the Observer will do is ...
0
votes
1answer
23 views

Override SenderBuilder class to add Bcc when sending invoice

I didn't found an event when invoice email is sent, so i tried to override Magento\Sales\Model\Order\Email\SenderBuilder class, the override is working but getting the customer attribute invoice_email ...
0
votes
0answers
13 views

Magento2 - add sales order custom attribute in checkout with validation in shipping section

I want to add 3-4 custom sales order attribute in checkout page in shipping section with shipping validation, attributes like text,checkbox.
2
votes
4answers
83 views

Magento 2.3.0 How to get request parameters in event observer?

I would like to get a request parameter in the observer file. Below is the observer code. etc/frontend/di.xml <event name="review_save_before"> <observer name="set_customer_data" ...
1
vote
0answers
34 views

Magento 2 - Recently viewed product not working with FPC

Magento default functionality of recently viewed product uses the following event to save viewed history catalog_controller_product_view And it stores in following tables ...
2
votes
0answers
11 views

Using Split Orders Extension but order confirmation mail is shooting for first order only instead of all

I'm using "order split" extension based on seller,means if there are 6 items in the cart having 3 different seller(have 2 item for each seller) then three orders(let's says order id as 500,501,502) ...
0
votes
0answers
13 views

Add additionnal receiver when sending invoice mail event

I'm new to Magento, i'd like to know how to override Magento function that send invoice email, by adding an additional receiver (other than the customer), or send another mail when an invoice is sent ...
2
votes
2answers
67 views

Magento 2 - Why does `sales_order_save_commit_after` not fire when user is not logged in?

I am using an observer to handle some logic when a new order is created or updated. The observer listen to sales_order_save_commit_after event, but I noticed that when the user is not logged in this ...
0
votes
3answers
67 views

how to get quote id before placing order M2

I am struggling to find which event I should use to get the quote id? I want to save some data in db, want to save customer session id and quote id before placing an order? Can someone suggest which ...
0
votes
1answer
31 views

Magento 2 - Order Item changes

I want to inform customers with email all the details of their orders and I want to be able to show the difference. For example: Those items shipped: ... Those items cancelled: ... Those items ... ...
0
votes
1answer
45 views

How to get Creditmemo ID from sales_order_creditmemo_refund?

If I observe sales_order_creditmemo_refund event, there’s no entity_id or increment_id data in the passed object. I presume those are added before the sales_order_creditmemo_safe_after event. However,...
1
vote
2answers
55 views

Get order increment id in observer

I have created a module to save order details to a custom mysql table after checkout completion. All works fine but the order id saves in the format "210"(order_id) instead of "1000000210"(...
2
votes
1answer
43 views

How to call dispatch events specific for Mobile?

How to call dispatch event for REST API's only in mobile devices.
0
votes
1answer
52 views

Why preference not working in Magento 2 observer (Custom module)

etc/di.xml <preference for="Custom\Pricerule\Observer\Frontend\Catalog\Catalog\ProductGetFinalPrice" type="Lof\RequestForQuote\Observer\ProductGetFinalPrice2" /> observer/...
0
votes
1answer
32 views

checkout_onepage_controller_success_action event save entry in custom table on order success in magento2

i have created event and observer checkout_onepage_controller_success_action now I want to save data in the custom table of order success when order is placed event.xml <?xml version="1.0"?> &...
0
votes
0answers
26 views

How to add massaction in product grid in magento 1

What is the easiest way to add add mass action to product grid using only observer and controller(no block). I would like to see a simple example because it is the first time I create it.
1
vote
1answer
45 views

How to redirect customer on custom page after registration in Magento 2

Here is my code customerregistersuceessobserver.php <?php namespace Webkul\Marketplace\Observer\Rewrite; use Webkul\Marketplace\Observer\CustomerRegisterSuccessObserver; use Magento\...
1
vote
0answers
31 views

Check stock at cart validation

I need to call a webservice to ckeck the stock of products in my cart. I added this observer: MyModule/etc/events.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/...
1
vote
3answers
63 views

Magento2: how to debug in sales_order_place_after event

registration.php <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Hafiz_Sms', __DIR__ ); etc/events....
1
vote
1answer
80 views

Magento 2: I need to run observer function through Cron job

I want to run an observer function through a Cron job. Can anyone share the simple observer function.? Here is my code <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
1
vote
1answer
59 views

pass array from php file to phtml?

i use observer on order place . sales_model_service_quote_submit_before when order is place i get order items and each item has a seller id . i get email from seller ids. and now send mail to those ...
0
votes
1answer
45 views

Set cookie in Observer Not working when full page Cache is enabled

I have to set category id in cookie when customer go to Category page and update cookie with category id when visit again using seperate module. I have created Observer and set cookie there but not ...
0
votes
1answer
36 views

How to get the custom attribute of products from the cart?

There is an attribute in the product AllowSameDayDelivery how can I get it out of the product? I got the products ids from the cart, But how do I get the attribute now? <?php namespace Ronis\...
0
votes
1answer
39 views

Does not work events magento 2

Events do not work when I go to the product page. events.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:...
0
votes
0answers
25 views

how to get the custom page event happened data to observer in magento 2?

I have custom module observer in Magento 2 <event name="controller_action_postdispatch_mpquotesystem_sellerquote_quoteedit"> <observer name="...
0
votes
2answers
30 views

Magento 2: catalog_product_save_after only for new products?

Ive made an observer for the catalog_product_save_after event, but I want to only fire it when a new product is added to the catalog. I did the same for the sales_order_save_after event and just ...
1
vote
2answers
118 views

Get current product id in Observer controller_front_send_response_before

catalog_controller_product_view event cannot be used in conjunction with FPC cache since Magento will not raise it after the first visit. That's why I am using controller_front_send_response_before ...