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
2answers
956 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 ...
1
vote
1answer
849 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
1answer
1k 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
2answers
930 views

how to trigger observer by rest api

I need to trigger observer whenever I call specific rest api I've created module/Observer/ObserverClass, module/etc/events.xml and module/etc/webapi-rest/events.xml but I don't know How to trigger it ...
4
votes
5answers
10k views

Magento 2 set & get Registry values

I want to set an array in registry in controller_action_predispatch_checkout_cart_add event observer and read this in a phtml page. The following code will give blank result . => Code : namespace ...
1
vote
1answer
843 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 ...
0
votes
0answers
17 views

Magento 1.9 how to run product alert notifications after updating stock item

I am updating products stock like this: $_product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku); Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); if ($...
2
votes
2answers
32 views

Magento 2 : Get shipping method using observer

I am trying to get the the shipping method using observer but I cant seem to get it to work, this is what I have for the ShippingTypeEmail.php <?php namespace vendor\Emails\Observer; use Magento\...
0
votes
1answer
825 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 ...
1
vote
1answer
188 views

How to call javascript function from Observer file in Magento 2

I have created a custom js file in my custom module. app\code\Vendor\Module\view\frontend\layout\default.xml <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/...
0
votes
2answers
25 views

Magento 2 - How to run a script asynchronously?

In Magento 2, I trigger catalog_product_save_before event. But this observer takes a lot of time to run and it result with a 504 error. So i would like to know if it is possible and how to run an ...
4
votes
1answer
1k 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 ...
2
votes
1answer
432 views

How to stop merging of non-loged-in cart items when customer logs-in?

I do not want to merge cart items if the user has items in cart and logs into the site. Let's go through the scenario: User logs in and adds one item to cart and logs out from a site. Now as a ...
0
votes
1answer
405 views

Magento 2 get customer old and new data on model_save_before and model_save_after event in admin backend

I am working on Admin Actions Log Extension. For the reference i am using the link below https://amasty.com/admin-actions-log-for-magento-2.html I want to get old and new data of customers when we ...
0
votes
2answers
20 views

Magento 2: Any Observer event trigger when product back in stock?

Hi guys I am looking for an observer event which triggered when product back in stock. So I do not know which Magento 2 event I have to be called when product back is in stock.
0
votes
1answer
15 views

how to passed array in product_form to observer in magento2

my phtml file code (below input tag is in for loop i=0 to i<5) <input type="text" name="array[]" value="<? echo $i ;?>" data-form-part='product_form'&...
0
votes
2answers
1k views

Magento 2 : Set free shipping method programatically from an observer

I need to add free shipping method fro particular quote in an observer. I am calling an event sales_quote_collect_totals_before. And my observer code is - namespace Vendor\Module\Observer; use ...
0
votes
2answers
17 views

Getting swatch value from checkout_cart_product_add_before observer

Is it possible to get the Swatch value id or name from the checkout_cart_product_add_before observer? I've passed the Product using $product = $observer->getProduct(); $productId = $observer->...
0
votes
2answers
800 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 ...
0
votes
1answer
1k views

Update total using 'sales_quote_save_after' event in magento 2?

I am trying to update Total amount if any user select "flat rate" shipping method. To achieve this, I've created a custom module using 'sales_quote_save_after' event observer. And getting user ...
0
votes
1answer
31 views

Get order Collection in Observer Class

I am working with an observer where i have to disable a payment method if user has no order existed and show it if at least one order existed. I am trying something like this but not able to get the ...
0
votes
1answer
28 views

Magento 2: sales_order_save_after called twice after place an order

I'm using Magento 2.3.4 and tried to catch the data order using sales_order_save_after observer like this: etc/events.xml <event name="sales_order_save_after"> <observer ...
3
votes
2answers
10k views

CE 1.9.2 - Custom sales_order_save_after observer fires twice

This has been driving me crazy for the last few hours now. I created a module to test sending Suppliers a custom email only once the order has been paid for (Order status changes to Processing). I ...
0
votes
0answers
9 views

How to access the product in a observer for layout_load_before for PDP page

I'm trying to access one of the attributes of the product in the observer for layout_load_before. But I'm getting an empty results. frontend/events.xml <config xmlns:xsi="http://www.w3.org/...
0
votes
0answers
6 views

Event “controller_action_predispatch” not working. Magento 1

Config.xml <?xml version="1.0"?> <config> <modules> <Vendor_Module> <version>0.1.0</version> </Vendor_Module> &...
0
votes
0answers
21 views

Uncaught TypeError: Unable to process binding “html: function(){return getInstructions() }” ( Magento 2 )

I'm using a third party one page checkout module on this system. And added an observer "payment_method_is_active" event for the cash on delivery and bank transfer methods to enable them only ...
0
votes
2answers
2k views

Magento 2 controller_action_predispatch observer not working as expected

I have created a Observer controller_action_predispatch which triggers in all page. Some thing happens strange with this When I clear all cache and login for the first time the observer triggers in ...
0
votes
1answer
43 views

I want to show the admin user on, change order status in bulk or single order

I want to show the admin user name on change order status in order comment history in bulk or single order, using a single event or plugin Magento 2.3.5p1 Community edition Any help highly ...
0
votes
3answers
1k views

Magento 2 extension - How to retrieve customer's data after registration

I need to retrieve id and email from the new customer after registration success. I imagine I have to bind the "customer_register_success" event, but my attempt is not working: etc/frontend/...
1
vote
4answers
1k views

Magento 2 checkout observer debugging

I'm trying to create a Module that gets the order data when an order is placed and sends it to a third party using FTP. I've created an Observer that gets called by the sales_order_place_after event. ...
2
votes
3answers
77 views

Magento 2: What is the best way to observe cart change to modify cart item in magento 2?

I'm using Magento v2.3.4 and i want to modify the cart item, if there is an update on the cart (add to cart, update cart item, and remove cart item). Currently I'm using plugin for quote collectTotals(...
1
vote
1answer
1k 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, ...
-2
votes
2answers
25 views

I want to get product id after order is paced using observer [closed]

events.xml <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> <event name=&...
4
votes
1answer
1k views

Adding custom column into product grid

I have created a custom column for associated products (basically every simple product will have that column under "associated products" tab of configurable product). I store information of this field/...
3
votes
3answers
4k views

Magento 2 - checkout_submit_all_after event is not working

In Magento, I have to get order items in the observer. I am trying two method sales_order_place_after and checkout_submit_all_after. Both events is not working. events.xml <config xmlns:xsi="...
0
votes
1answer
15 views

How to detect the page handle in my observer?

I want to avoid the execution of my observer in case the page handle contains checkout or catalog, how could I do it?
2
votes
1answer
2k views

Get selected Custom Options from configurable product

the following observer script looks for selected configurable options, to work out the qty needed and adds a simple product (#9236) to the cart. However, it only works for simple products. How can I ...
5
votes
1answer
1k views

Render Javascript on customer_login event

I'm trying to render some javascript when the customer_login event fires by accessing a block on the layout from within the observer. I've successfully registered my observer to execute with the ...
2
votes
4answers
2k views

Add Qty to Product before adding to cart

I am looking for an event observer which is suitable for my requirements. My requirement is I add to cart the product but qty I want to add to this cart will be decided by the product attribute. I ...
0
votes
1answer
19 views

Only partial order object in `sales_order_invoice_pay` observer when subtotal is zero

I have an observer for the sales_order_invoice_pay event with the following code. public function execute(\Magento\Framework\Event\Observer $observer) { $order = $observer->getEvent()->...
17
votes
7answers
60k 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->...
0
votes
1answer
11 views

How do I know what data I can access via an observer?

I'm trying to use the sales_order_invoice_pay observer. I can see the dispatch in: /vendor/magento/module-sales/Model/Order/Invoice.php $this->_eventManager->dispatch('sales_order_invoice_pay', [...
5
votes
3answers
2k views

Does Paypal Express not dispatch checkout_submit_all_after event? If so how can I make it do it?

I have several modules that rely on the checkout_submit_all_after event and when users checkout using Paypal express it seems none of their observers run. How would I go about fixing this?
1
vote
1answer
1k views

Prevent abandoned cart and guest cart merge

I have made Observer on event "sales_quote_merge_before" to remove abandoned cart items when customer logs in (from Go to Checkout). After login Minicart shows only guest cart items (no items from ...
1
vote
1answer
1k views

Order status change on sales_order_place_after event not working

I'm trying to change status of order as hold by calling an observer on sales_order_place_after event. When I log the order object, it shows that order status has been set to 'hold' but when I check ...
0
votes
1answer
13 views

layout_generate_blocks_after observer is not redirecting to checkout/cart page in Magento 2

I'm using the observer layout_generate_blocks_after to perform redirection to an empty cart on a condition but it is not redirecting. Any help would be appreciated. Here is the piece of code which i ...
0
votes
2answers
918 views

Cart items will not be deleted in observer

I searched a lot but none of the solutions worked for me, I am trying to delete an Item from observer but if there is only one item in cart it works with removeAllItems() but if there are more than ...
0
votes
2answers
1k views

Add to Cart Resulting in: Cannot add the item to shopping cart

I have this observer listening: sales_quote_product_add_after Inside the observer I run this code to change the price of the item when added to the cart. $item = $items[0]; $request = Mage::...
6
votes
2answers
591 views

Apply Tax to the cart total based on product attribute value magento 2.3

I am applying custom tax for the cart item based on the product attribute value. used below event for that. Vendor/Module/etc/di.xml <type name="Magento\Quote\Model\Quote\Address\Total"&...
0
votes
1answer
784 views

Magento 2 can't update customer custom attribute value at customer observer(customer_save_after)

I am trying to save customer custom attribute value at customer_save_after observer. but observer script is not working at observer but that script working at contoller. events.xml <event name="...

1
2 3 4 5
40