Questions tagged [event-observer]

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

Filter by
Sorted by
Tagged with
3
votes
2answers
2k views

Magento event after filling checkout shipping address

Which magento event gets triggered after filling shipping address on checkout one page as I need to pass some information to a third party api just after shipping address.
1
vote
2answers
1k views

Events and observers; what is being cached?

I am using Cloudflare to retrieve the Geo IP of a user. When using this in pub/index.php it always works and I am able to set the correct store view based on the header Cloudflare is passing. ...
1
vote
2answers
17 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
3answers
511 views

magento 2 sales_order_shipment_save_after does not fire

I created an observer for changing the shipping method amount but it does not work. This is my code Cop/Postexpres/etc/events.xml <?xml version="1.0"?><config xmlns:xsi="http://www.w3....
0
votes
1answer
27 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
22 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
45 views

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

I need to redirect to next controller after registering page.
1
vote
0answers
40 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\...
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. ...
2
votes
2answers
250 views

Event dispatched on filter applied in Product Listing/Category View page

I have a module where I want to send data to an API whenever any filter is applied on the product listing/category view page (list or grid). The data being sent should contain only the latest filter ...
1
vote
0answers
18 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
2k views

How to update subtotal after changing price with observer

I am using observer to change bundle product price. I have tried events 'checkout_cart_product_add_after' and 'checkout_cart_save_after'. Both events update product's price but subtotal remains same. ...
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 ...
0
votes
3answers
71 views

Unable to redirect to cart page from observer?

Here is the code, please review and advise. Demo/Test/etc/frontend/events.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
1
vote
0answers
8 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
18 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
2answers
738 views

Magento2 : Redirect Page From Observer

I want to restrict some unwanted users to access the site. So I am redirecting them to 404 Page but my logic is going to an infinite loop as the event I am calling from controller_action_predispatch ...
0
votes
1answer
20 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. ...
0
votes
1answer
41 views

How to run CLI Command on the product Save/update in Admin Magento2

How I can run an indexer command after save or update the product in the admin through any observer or any plugin? I want to run "bin/magento wyomind:elasticsearchcore:indexer:reindex product" ...
0
votes
1answer
35 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 ...
0
votes
1answer
19 views

Magento 1.7 : How to use sales_order_payment_capture event?

In Magento 1.7, I want to do like after credit memo create product quantity should be deduct. How to do that? Any help would be appreciated. Thanks.
1
vote
2answers
41 views

Success Event for Order place on Admin side

I want to know which event is used for firing when an order successfully placed by the admin. Right know i am using an event sales_order_save_commit_after. The problem her i am facing is that while i ...
2
votes
2answers
36 views

Where is the event sales_order_save_before dispatched?

I am tring to figure out when sales_order_save_before is dispatched but I do not see it in the source. What class is responsible for dispatching this event?
1
vote
2answers
651 views

Add a block to a page with event observer

I'm trying to add a static block to a page with an observer. The event that I'm listening to is controller_action_layout_generate_blocks_after and this is my observer code: <?php ... class ...
1
vote
0answers
18 views

Magento 2 How to store quote custom data into sales_invoice

I have created certain custom columns in quote, order, invoice and shipment tables and all the table columns are labeled with the same. Now i am able to store the data in quote and quote->order table ...
0
votes
0answers
17 views

Get Order Comment Event Magento 2

I want to get a comment which submits when order view. I use this event sales_order_status_history_save_after and it fire when submitting a comment but I am struggling to get a comment which user adds....
0
votes
2answers
1k views

Address update get street problem magento 2

I am using "customer_address_save_after" event. This is my observer code. public function execute(\Magento\Framework\Event\Observer $observer) { $address = $observer->getEvent()->...
1
vote
3answers
640 views

Magento 2 - Error trying Redirect to login page for controller if not logged in

I know this question has been asked before a couple of times here: Magento 2 : Redirect From Homepage to Login if not Logged Magento 2 - Redirect user to a specific page if not logged in However i ...
1
vote
1answer
1k views

How to recognize order before saving in the backend ? - Magento 2

I would like to post some data in admin order create form and check if it exists and is set if not throw an exception. I was thinking about adminhtml_sales_order_create_process_data event, but it is ...
4
votes
1answer
2k views

Problem with overriding of observer

What I'm trying to do is to override one single method in Model/Observer.php of other module. I followed this tutorial: http://www.atwix.com/magento/overriding-observers/. As a result I've created my ...
1
vote
0answers
56 views

Redirect to login with add cart button for guest user

I'm trying to redirect guest users to the login page when they click on the Add to Cart button and they are not registered. But I can't do it. I am using an Observer with the following event <...
0
votes
1answer
700 views

Custom price of product not getting applied in cart in Magento 2

I am trying to set the custom price of product to cart using Magento2 but unable to do that. For that I have created a module TW - as namespace Cart- as Module name . So under TW/Cart I have created 2 ...
2
votes
3answers
2k views

Check action noRoute (404) on Every page using Observer not working Magento 2

How to check action noRoute (404) on every page using Observer? etc/events.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
0
votes
1answer
33 views

Magento2.3 : Unit Case writing for Observers

I was wondering what is best practice for Unit test case writing for observers ? I looked for examples in core , and found below file magento/module-sales/Test/Unit/Observer/...
3
votes
4answers
227 views

Magento 2 Is it possible to use same event in multiple Modules?

I wanted to use catalog_product_save_after event in 2 different modules, Is it possible to use it? Please help me!
0
votes
0answers
34 views

Magento 1.9 - What event used for observe Minimum Order Value Condition?

Selected customer able to place an order even minimum order condition applied. Eg: My store Minimum order value: 500 if selected customer order value 200 he should place an order. What event used for ...
0
votes
0answers
13 views

how can I convert an attribute value of type date to php datetime object in Magento 1.9

I have created in the backend a product attribute called estimated_date and I would like to manipulate it in an observer for catalog_product_save_after. So from my catalog/product model I would like ...
0
votes
1answer
37 views

Custom Captcha not working in Magento2

I want to show captcha in Product Review Form, Followed the below link. Magento 2: How Captcha Module works? Created the module with relevant files and I am able to see the captcha in review form. ...
2
votes
1answer
44 views

How can I update customer custom attribute on order save?

I have an observer for the event when an order is placed by a customer. I tried "sales_model_service_quote_submit_before" I would like to take a value from the Order and save it to the customer. For ...
0
votes
2answers
105 views

Magento 2 - Adding custom layout handle for layouts (1 column, 2column etc) set via product admin page

I want separate layout handles defined for products dependent on their layout set via the layout options for product within admin (1 column, 2 column left, 2 column right). I need to set additional ...
0
votes
2answers
5k views

add product to cart and change price and weight

I need a module that when you add product to cart check two conditions and if they are correct will change the price for the product in the basket. I need do something like this: - when product is ...
6
votes
5answers
3k 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). ...
8
votes
6answers
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 ...
1
vote
2answers
643 views

Update custom attribute when product data updated through import

We import product data using a feed we get from a wholesaler - one full import a week that merges product data and a daily import that only updates price and stock data. I have created a custom ...
0
votes
1answer
13 views

Magento 2.2.2 custom observer attribute name not valid atomic type

I have a custom observer for admin admin_system_config_changed_section_{{$section_name}} the following are: events.xml: <?xml version="1.0" encoding="UTF-8"?> <config xmlns:xsi="http://www....
0
votes
2answers
45 views

Magento 2 observer is not triggering

We are going to use controller_action_layout_generate_blocks_before frontend event in M2. please note same event which is working on M1 but it is not working please review my below code and share ...
11
votes
3answers
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,...
1
vote
1answer
744 views

How to set cookie on salesQuoteSaveAfterObserver in magento2

In my custom module events.xml <event name="sales_quote_save_after"> <observer name="cedapi_set_checkout_quote_id" instance="Vender\Module\Observer\SalesQuoteSaveAfter" /> <...
2
votes
0answers
24 views

Magento2 - update to custom status after shipment creation

I created an Observer that makes some execution based on the company needs using event sales_order_shipment_save_after. It does everything I need except changing the order status to a specific. I ...
1
vote
1answer
707 views

Get order id after Paypal Express Checkout

I want an order Id (not Increment Id) and quote after redirecting back from PayPal to my store. For this purpose I am using sales_order_place_after event. But this event does not return order Id ...