Questions tagged [event-observer]
Event/observer is used to work dynamically with Magento without altering the core code.
2,150
questions
0
votes
0
answers
23
views
Write Magento2 Custom Module to set Minimum Order Amount for Selected Customer Groups
I developed a Magento 2 module to add customer groups dropdown in admin panel Store-> Configuration -> Sales -> Minimum Order Amount so I can set min order amount only for some customer ...
0
votes
1
answer
48
views
Getting child product of configurable in Observer?
Magento 2.4.6
I am listening to the checkout_cart_product_add_after event. In my observer I am trying to get an attribute from the added child product. I did not manage so far, all data that I get is ...
0
votes
1
answer
37
views
Magento 2 - Get Stock Update Observer
My observer is not getting product information, this line is always printed
$this->logger->info('Product object is always null.');
<?php
namespace Custom\Module\Observer;
use Magento\...
2
votes
3
answers
115
views
Prevent invoice email notification after invoice creation in Magento 2
I have used below event to stop Invoice email notification that is triggered after the invoice creation.
Vendor/Module/etc/events.xml
<?xml version="1.0"?>
<config xmlns:xsi="...
1
vote
1
answer
31
views
Event observer hangs on order creation
Situation:
I'm creating a Magento 2 module that listens to specific event observers, gets the ID's associated with those events, and sends them to a third-party Node app. This Node app will receive ...
0
votes
0
answers
21
views
Update product quantity after place an order with my own Observer event
I have created a new Observer event where I check sibling products. Sibling product are products with same pid.
After placing the order, I would like to reduce the quantity of siblings of the product ...
0
votes
0
answers
22
views
Skipping min sale qty validation when adding product to cart?
Magento version 2.4.6
I am listening to the checkout_cart_product_add_after event to modify the price of a product when it is added to the cart. That works just fine.
Now, if the product has a min ...
0
votes
2
answers
85
views
sales_order_item_cancel Event Not Triggered when Canceling Order Programmatically using $this->orderManagement->cancel($orderId);
I'm currently working on a module that involves the programmatic cancellation of orders. To cancel orders, I am using $this->orderManagement->cancel($orderId); in my code. This appears to be ...
1
vote
0
answers
15
views
Changing item name when being added to cart? [duplicate]
Magento 2.4.6
I am using the checkout_cart_product_add_after event to modify the price of the product which is added to the cart. This works just fine. Changing the name however does not work. I tried ...
1
vote
2
answers
30
views
Getting simple product in observer when adding configurable product to cart?
Magento 2.4.6
I am trying to get the simple product of a configurable product when a product is added to the cart. I am listening to the checkout_cart_product_add_after event. This is what I have so ...
0
votes
1
answer
30
views
Knowing which button was clicked on the product page in an observer?
Magento 2.4.6
I added a button to my addtocart.phtml. Below the button I added a hidden field, like this:
<button type="submit"
title="<?= $buttonSampleTitle ?>"
...
0
votes
1
answer
48
views
How magento schedule update for magento product programmatically?
How i magento perform schedule update programmatically.
which module i check, how magento perform schedule update ?
please narrate which file work ?
0
votes
1
answer
37
views
How magento 2 default content scheduling work programmatically
what is the logic behind the content scheduling in magento 2.
Using cron ?
using event observer ?
1
vote
0
answers
31
views
Dispatch custom event for all methods that extends a parent method
I'm developing a module that will be extended by other modules. Here I will call the parent module as parent and the "child" module (the module that will extend the classes from parent) as ...
0
votes
1
answer
42
views
How can i put the value from observer/event into a dropdown
I have a dropdown menu, How can i put the value from observer or event to a dropdown on checkout page. Thank you in advance.
0
votes
1
answer
92
views
Trying to listen to the add to cart event
This is my first time playing around with Magento. I'm building a module and I want to listen when a product is added to the cart so, I've tried to use the ...
0
votes
0
answers
16
views
Magento 2: Dynamically ignore tier price configuration upon add to cart action
I have modified a product in a way that you can either buy it "as usual" or decide to buy it as a subscription (via custom options). If you decide to buy as subscription tier prices should ...
0
votes
0
answers
16
views
Magento 2: Dropdown function before "Place Order"
Good day! i'm a newbie in magento, i've already created a custom payment method. I would like to replace the "success" and "fraud" into payment gateway e.g. Paypal & Paymaya. ...
0
votes
0
answers
16
views
How is it possible to stop sending any type of mail from Magento 2 based on the customer email value?
I am working on Magento 2.4 version and certain events that were available in older versions are not there now. I guess a plugin would be an ideal solution to this. Any suggestions would be much ...
0
votes
2
answers
272
views
Magento 2: How to pass the parameters to another URL?
I'm new in magento 2, my question is how to send parameters with results responses to another url whenever i click "Place Order" and before proceeding to success page. Using event and ...
0
votes
1
answer
191
views
magento 2 - list sales order status all events
I search for all events used for sales order status.
sales_order status events
magento 2.4.4
0
votes
1
answer
28
views
Magento Observer Dispatching
I am little bit confuse about Observer Dispatching. What it means by. Can Anybody expalins me.
0
votes
1
answer
222
views
Magento 2 Unable to update customer data during passing to customer login observer
In magento 2 I am trying to update session_cutoff column in table customer_entity during login
Below is my code which I add in observer using event customer_login
public function execute(\Magento\...
0
votes
1
answer
22
views
How to get the current product details in Observer without registey
How to get the current product in Observer instead of this "$product = $this->_registry->registry("current_product");"
I need the code for without registry in the observer.
0
votes
3
answers
118
views
How to get current product in magento 2 observer without registry
I need to get the current product details in magento2 observer without using the registry.because magento latest version is deprecated this registry.
I need the current product for reviews. when ...
0
votes
0
answers
131
views
Magento 2.4 : How to save delivery comment in order and in database?
I'm using Magento 2.4.4 and PHP 8.1 . How can i use the order comment as show in screenshot but use it in shipping method as delivery comment and save comment in sales_order "e table?
I have ...
0
votes
1
answer
42
views
Intercept payment method change
I am working on a custom extension where I need to call an observer when any payment method is selected from the available payment method list on the frontend checkout page.
Unfortunately, I didn't ...
0
votes
0
answers
94
views
Magento 2 Unsubscribe is not working
We are using Magento 2.4.0.
We override email templates of "Subscription Success" and we add a link to "Unsubscribe" but all these 4 are not working -
{{var subscriber....
0
votes
2
answers
349
views
Magento 2 - Class not found
I always get this error if I try to load my site, even though the class does exist.
PHP Fatal error: Uncaught Error: Class 'Company\\App\\Observer\\Frontend\\Controller\\ActionPredispatch'
app/code/...
0
votes
1
answer
74
views
How to insert html content on a page in Observer?
How to insert html content before the </body> tag, via Event and Observer on each page?
1
vote
1
answer
94
views
Can I use sitemap_products_generating_before event to modify Product Sitemap in Magento2?
In Magento 1, sitemap_products_generating_before event allows us to modify the Product Sitemap.
Can I use sitemap_products_generating_before event names in Magento 2.4?
I want to filter the product ...
0
votes
2
answers
77
views
How do I transfer data from one Observer to another?
I need to pass the value of a variable from one Observer that monitoring the cms_controller_router_match_before event to an Observer that monitoring the cms_page_render event. How can this be done ...
0
votes
0
answers
87
views
Correct way to remove and add product to order on sales_order_place_after event
I'm trying to use the sales_order_place_after event to remove or add products to the order only after successful payment but facing a few different problems.
There are a few different solutions I ...
0
votes
1
answer
36
views
Observer display return to frontend
I would like to display the result from Observer to every page, any way I can do it?
app/code/MyVendor/GeoIp/Observer/GeoObserver.php
<?php
namespace MyModule\GeoIp\Observer;
use Magento\...
1
vote
2
answers
400
views
Magento 2 - detect orders that are placed via REST API
Is there a way to detect orders that are placed via API? I want to add to those orders a different order number prefix.
I have already created an observer that is changing the prefix based on payment ...
1
vote
1
answer
180
views
magento 2.4 observer on product image change
I have a grouped with some associated products. When the image on the grouped is updated, I'd like to save the same image on the associated products also.
I tried with the "...
0
votes
0
answers
38
views
Magento 2.4 - How to get event name for a specific mail
I'm trying to add a custom variable for the new customer with no password template but I'm struggling to understand which event I have to observe
I need the name of the event and other useful info
...
0
votes
0
answers
72
views
Unit Test Case for Order Event sales_order_load_after
I have create a observer for sales_order_load_after event, and now creating unit test case for this method but not identifying on code coverage.
one of the execute method created like
public function ...
1
vote
1
answer
604
views
Magento 2.4 - Observer For Catalog Product Save After Not Working
I have referenced a few different questions here and other articles online, but cannot for the life of me determine what is going wrong.
Referenced:
Event not triggered when new product added in ...
0
votes
0
answers
47
views
Adding custom button on product page and add another product to cart on click?
Magento 2.4
I added a new button to the product page, this is how it looks:
<button type="submit" title="Add to cart 2" class="action primary tocart" id="product-...
1
vote
1
answer
53
views
unable to get the Customer Custom Attribute value in customer_register_success event in magento 2
In my project a custom customer attribute was using and save the value in the table on customer registration. Attribute id was phone_number
I want to get this phone number value and send an sms using ...
0
votes
1
answer
324
views
Magento 2.4.4: How to get Gift Message from Order object in my Observer class subscribed to checkout_onepage_controller_success_action?
With upgrade to Magento 2.4.4, I'm using checkout_onepage_controller_success_action to get order information that I insert into a custom table that I created in Magento. We're allowing customers to ...
0
votes
0
answers
131
views
Magento 2.4.5: What is the right event to retrieve all payment information
With the upgrade to Magento 2.4.5 from 2.4.2, the old code in an observer class in the custom module to get information about Stripe Payment isn't working any more. It looks like Magento event ...
1
vote
2
answers
54
views
Magento 2.3.5 order email observer custom block enable to pass array
I have tried the following:
Observer
...
$transport = $observer->getTransport();
$transport->setTemplateVars([
'products' => [
['name' => 'Product1'],
['...
0
votes
1
answer
230
views
Magento 2 - Check if customer and customer addres created from admin backend
Is there a way in Magento 2 to check/know if a customer and a customer addres is created/edited from admin panel ?
I was thinking using a oberver on customer_address_save_before and ...
0
votes
1
answer
253
views
How to check that my observer file was called from admin or frontend in magento 2?
I am using sales_order_save_after in Global scope. I am creating orders from admin programmatically( Order, Invoice and Shipment). Each and every time this event is calling.
I want to check and update ...
1
vote
1
answer
1k
views
Magento 2: The resource isn't set
I'm using Magento 2.4, I created an event & observer checkout_submit_all_after, and after placing an order I get the following error below in the log. Thanks for the help.
LOG
main.ERROR: The ...
0
votes
1
answer
231
views
How to change first name in shipping address on this page using event observer magento 2?
Please explain with examples and provide the code of execute method if possible.
3
votes
1
answer
1k
views
How can I change the shipping price at checkout with an observer or plugin?
The shipping method may be flatrate or FedEx or freeshipping, but I want to override this price with $1. How can I do this?
0
votes
2
answers
162
views
override checkout index controller
I would like to override only one line in checkout/index/index controller.
do I need to use preference or plugin or observer?
if (!$this->_customerSession->isLoggedIn() && !$...