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.

2
votes
0answers
58 views
+50

Observer for Abandonment of Cart

I need help!!! I am creating a module that integrates with another platform via API. I already got the Observer or Event for customer registration (customer_register_success), purchase completed (...
1
vote
1answer
887 views

Magento 2 direct sql query for insert not working

I was trying to insert values into mlx_cot_custom_option_type_value because module files are encrypted.I want to add something after product save i am using catalog_product_save_after event Here is ...
0
votes
1answer
29 views

Trigger checkout validation only on change event

So I have these code to validate a generated field in the shipping address: VAT number The requireJs: app/code/VendorName/Checkout/view/frontend/requirejs-config.js var config = { config: { ...
0
votes
1answer
23 views

Order/Invoice Paid Event

I'm trying to find an event/observer which will fire once an order is paid in Magento (2.2.8). checkout_onepage_controller_success_action - seems limited to frontend orders (ie not called for admin ...
0
votes
2answers
35 views

Event “customer_register_success” not working in Magento1.9.2.4

Here is the code- app/etc/modules/Ds_Customerlog.xml - <?xml version="1.0"?> <config> <modules> <Ds_Customerlog> <active>true</active> <...
0
votes
2answers
6k views

Get order Details from Magento 2 Observer

I am trying to build a Magento 2 Order Observer in which I am trying to get the Product Details such as Product ID, Product Name, Product SKU, Product Quantity and Customer Details such as Customer ID,...
0
votes
1answer
26 views

What is the correct event for collecting/updating order information after order success?

I've seen multiple people use save_order_place_after, as well as checkout_onepage_controller_success_action. My issue is that I want to do a quick scan of information collected on that order, and ...
1
vote
1answer
26 views

Fire Observer for any page request within Magento 2?

Actually in my case i want to run observer which would just work like index.php bootstrap initialisation file. Here I want here it should be work for each page request within Magento 2. ...
1
vote
1answer
746 views

sales_order_place_after not firing for admin-created orders

I have a simple custom module that sends a separate email to an admin user once an order has been placed (email uses a different template). This email is supposed to work for orders placed from the ...
1
vote
1answer
22 views

When I use “echo” in vendor methods - products not showing, but work fine without it

I got the next code: public function getProductCollection() { if (isset($this->_productCollections[$this->getCurrentCategory()->getId()])) { $collection = $this->...
0
votes
0answers
15 views

Observer for event on Checkout button click of Minicart Magento 2

I want to create observer for event which is responsible to send data from minicart to checkout. Please suggest event name. I have already tried: checkout_cart_update_items_before and ...
0
votes
1answer
737 views

Admin order update price programmatically in quote loop

I have a bit of custom pricing that needs to be carried out for each product in an order which alters the end price of the item. I am using an observer with the sales_quote_item_qty_set_after event ...
0
votes
2answers
28 views

Magento 2 - How to call sales_order_save_after Observer manually for testing?

i have a working Observer on the event sales_order_save_after. The Observer looks like this: namespace Company\ExportOrder\Observer; use Magento\Framework\Event\ObserverInterface; class Observer ...
3
votes
0answers
23 views

Save value of custom field in minicart to order Magento 2

I have added one field "Special instructions" (textarea) in mini cart which I want to get saved in order details when customer put the order. In which observer can I get the value of this field? and ...
0
votes
1answer
17 views

How to get formatted custom price

I have set my product custom price in an observer.. $item->setOriginalCustomPrice(9.99); $item->setCustomPrice(9.99); I can output the price value correclty like so: echo $item->...
1
vote
1answer
25 views

Event after remove customer Magento2

How to create an event on customer remove from backend.? what is the name of the event? I need to remove customer's data from my custom table after removing a customer from the backend.
0
votes
1answer
819 views

How to update the layout file in observer

public function CodeOrdeStatus(Varien_Event_Observer $observer) { $order = $observer->getEvent()->getPayment()->getOrder(); $order=Mage::getModel('sales/...
0
votes
1answer
21 views

Magento 2 | event before checkout#payment

is there an event which gets fired before you get to checkout#payment? Thanks!
0
votes
1answer
14 views

Update all quote items with qty 1 in magento2

I am trying to update all the quote item qty as soon as we navigated to the cart page. by using below code. $quote = $this->checkoutSession->getQuote(); $quoteItems = $quote->...
2
votes
2answers
81 views

Magento 2 | Is there an observable event for when the checkout begins?

when the checkout is started I need to modify the quote. Is there an event when the checkout is started? Thanks in Advance!
1
vote
1answer
744 views

Custom Order Status for Cancel not working

I have the following observer method thats been called successfully, but the order status is not changing. public function customCancel(Varien_Event_Observer $observer) { $order = $observer-&...
1
vote
1answer
752 views

using event after catalog collection load doesn't get the count right

I'm trying to modify items in a collection on page load (catalog) and using the event: catalog_product_collection_load_after and the code for the event is : $observer->getCollection() ...
1
vote
2answers
33 views

Programatically deleting items from cart leaves 'ghost' items;

I am using the observer checkout_cart_save_after to programatically delete some cart items. public function execute(Observer $observer) { $cart = $observer->getCart(); $quote = $cart->...
-1
votes
0answers
23 views

Magento 2 - How to get product tier price in cart?

I have set product tier price and I want that tier price in cart using Event Observer. Can anyone help me which event is use to get tier price. Note: I want tier price from quote not from product. ...
0
votes
2answers
2k views

How can I programmatically perform a 301 redirect in Magento 2

Today I am trying to redirects 301 pro-grammatically. But I have problem from $this->_responseFactory->create()->setRedirect($CustomRedirectionUrl , 301)->sendResponse(); line. I have ...
0
votes
0answers
16 views

Magento 2 :- How to get newly added options id of product attribute & Deleted option id of attribute

I want to get lastly added product attribute options id and also need to deleted option id in the following event: catalog_entity_attribute_save_after Anyone can help me with this?
3
votes
1answer
837 views

Programatically set product attribute defaults - Magento 2

My specific use case is that I want to set the news_from_date and news_to_date for the a thirty day period from when the product is created. I would like this to work so when a user goes into the ...
0
votes
2answers
754 views

checkout_cart_update_items_after is not working

I'm stuck in this. The checkout_cart_update_items_after is not firing. I already put a log statement in the function but is not getting executed. Whereas checkout_cart_product_add_after is working ...
0
votes
1answer
22 views

When add second product, custom attributes not save data. Using event “ sales_quote_item_set_product ” in Magento 2

I used the sales_quote_item_set_product event to save data to the table when adding to cart product. It works but when I add the next product, it does not save the old data in the old field. My ...
1
vote
2answers
24 views

Magento 2 event observer custom config save given error

I have a custom section tab in configuration my section url is: http://dev.test/admin/admin/system_config/edit/section/vendor_module/key/????????? exception(s): Exception #0 (Magento\Framework\...
1
vote
1answer
1k views

Magento2 get group product child that was added to basket

When adding a grouped product to the basket you actually add a child product not the parent product. We are hooking into this event: checkout_cart_add_product_complete but the product returned by ...
0
votes
2answers
758 views

Update default address in customer_save_after observer

I am trying to update a customer's default billing address when they update their main account information. My observer function looks like this and for the time being I am hard coding in the prefix ...
1
vote
1answer
30 views

Magento 2.2 - event to detect qty change

I need to detect a change of qty in product (backoffice change after edit is enough for me). I was trying to do it with simple observer <event name="cataloginventory_stock_item_save_after"> ...
0
votes
0answers
8 views

How to save offline custom payment drop-down data in sales order and Display in sales grid

I created one payment method swipe machines. That swipe machine have a master. We are saveing Machine Name,Tid,Mid, Percentage in master. In payment section of swipe machine we are just looping data ...
1
vote
1answer
29 views

How is $this->eventPrefix built?

Mangento has something that is called dynamic events. This are events dispatched as follows $this->eventManager->dispatch($this->eventPrefix . '_load_before') After what rules is the value ...
0
votes
1answer
29 views

Magento 2 checkout_cart_product_add_after not working

here am trying to add custom price during adding product to cart but checkout_cart_product_add_after event is not getting fired. my API to add to cart is http://localhost/magento/rest/V1/carts/636/...
0
votes
1answer
22 views

Magento 2: Event-Observer for whenever the stock status of product changes

Is there an event for whenever a product goes from In-Stock to Out of Stock and vice-versa. I basically need to programatically set the value of a custom product attribute depending on the stock ...
1
vote
1answer
30 views

How I can add custom block to layout using php in Magento 2

I have created a custom block, as I want to add this layout to my current layout. Following is my block: <referenceContainer name="sidebar.main"> <block class="Vendor\ModuleName\...
2
votes
1answer
44 views

Change quote currency before place order

I want to change my quote currency code to EUR when an order is placed in any other currency. I tried writing event and observer of event sales_order_place_before. In my observer I have this code ...
0
votes
0answers
24 views

how i can get parameter value in plugin into magento 2 observer

i have plugin for customer account create public function aroundExecute( \Magento\Customer\Controller\Account\Create $subject, \Closure $proceed ) { $getid = $subject-&...
0
votes
1answer
25 views

how i can get parameter value of url parameter in customer registration success observer magento 2

I have set link like this http://localhost/magento/customer/account/create/?param_id=20 how I can get that (param_id) value in customer registration success observer in Magento 2 how I can do ...
0
votes
0answers
8 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
31 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
2answers
31 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 ...
1
vote
2answers
984 views

Magento 2: Observer getRequest not working and product added issue

I have below observer namespace Custom\Module\Observer; use Magento\Framework\Event\ObserverInterface; use Magento\Framework\App\Request\DataPersistorInterface; use Magento\Framework\App\...
1
vote
1answer
494 views

How to create plugin for observer magento2

I want to create Plugin for observer SalesOrderAfterPlaceObserver, I created a di.xml file and added below coded, <type name="Magento\SalesRule\Observer\SalesOrderAfterPlaceObserver"> <...
0
votes
2answers
51 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
980 views

Magento 2: How to use event trigger on the checkout page?

How to use event trigger when change "State/Province " drop-down on the checkout page? I'm trying to page reload when user change Region from "State/Province" dropdown in the checkout page. First, ...
1
vote
2answers
549 views

can we create two observer with same event in Magento2?

I need to create one observer after the customer is logged in. I found this is the event name customer_login My point is I installed one third-party module for some requirement. Where that extension ...
1
vote
1answer
56 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);...