Questions tagged [event-observer]
Event/observer is used to work dynamically with Magento without altering the core code.
2,158
questions
0
votes
1
answer
15
views
Get same product info while we use catalog_product_save_before and catalog_product_save_after
when i am using catalog_product_save_before and catalog_product_save_after
this two event it will always return catalogue_product_save_before data.
when I am trying to fetch the child id from the ...
0
votes
2
answers
37
views
Showing the product in category and search with Magento 2 Observer
I have defined an attribute in Magento 2. When I say Dont Show in Category in this attribute, I do not want the product to be shown in Category and Search. But I don't want to completely remove the ...
0
votes
0
answers
20
views
Custom Attribute not saving into the Sales_Order Table
This is my PLugin :
<?php
namespace Vendor\Module\Plugin;
use Magento\Sales\Api\Data\OrderItemExtensionFactory;
use Magento\Sales\Api\Data\OrderItemInterface;
use Magento\Sales\Api\Data\...
0
votes
1
answer
31
views
how to save data to my custom column in customer_address_entity
i have made custom column called coord in customer_address_entity using db_schema.xml
<!-- add coordinate to customer address entity -->
<table name="customer_address_entity" ...
0
votes
0
answers
27
views
Magento2: Insert order grid data into a custom table using the sales_order_save_after event
I have created an observer with this event file.
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events....
0
votes
0
answers
33
views
Magento 2 Mailchimp Guest customer fields are not sync on Mailchimp after order placed
Magento 2 Mailchimp Guest customer fields are not synced with Mailchimp after the order is placed.
We are using Magento 2.4.5-p1 version and the Mailchimp version is 103.4.50
Except for Guest email ...
0
votes
1
answer
91
views
Magento2: Issue with the customer custom attribute and custom tab in product view
This is the code snippet responsible for adding new attribute
public function createAllowRequestSampleCustomerAttribute($setup)
{
$code = 'allow_request_sample';
/** @...
0
votes
1
answer
28
views
show an error message in adding item to the cart if the user is not logged and the item have price greater than 100 that item shouldnot added to cart
'''
public function execute(Observer $observer)
{
$item = $observer->getEvent()->getData('quote_item');
$product = $item->getProduct();
if ($product->...
0
votes
0
answers
21
views
Magento 2: Override theme conditionally fails
I have a certain route in my store for which I want to switch to magento's luma theme.
I used the layout_load_before event and created an oberserver to do that:
namespace My\Module\Observer;
class ...
1
vote
1
answer
44
views
Redirect to Home after login
I've been strugling with this a lot, I have to redirect the users to Home when they login to the site. I've been following solutions given in other questions about the same, but nothing works, here ...
0
votes
0
answers
19
views
How to toggle custom tab visibility in product view with event observer based on custom attribute's value (custom layout handle)?
There is a custom tab "Ask Question" in a product that has a form (it has a logic for saving data to the database).
My task is to create an event observer for the attribute that I have ...
1
vote
1
answer
54
views
Not Display Product Name in the Email template?
module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/...
0
votes
0
answers
20
views
Magento 2.4: Pass jQuery value into checkout_cart_product_add_after observer
I have done some custom price calculation on product page using jQuery and I want to add the calculated price to the product during addtocart event.
Any help would be appreciated.
1
vote
0
answers
31
views
i need to create a observer that will change all products prices on category page
this is my events.xml code
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation=&...
0
votes
1
answer
34
views
Change layout based on url parameter - Magento 2.4
We created a custom module, to load a observer before layout_load_before. And then we would like to change the custom layout, based on a url parameter ?content-only=yes. For some reason it does not ...
0
votes
1
answer
48
views
how to create a customer by using two fields passwords and confirm password in email section on magento2 checkout?
I have two fields created at the email section in checkout in magento2. I want to create a customer on order place. I am currently using "sales_order_payment_save_before" to get field data ...
0
votes
0
answers
30
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
139
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
123
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
347
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
51
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
26
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
30
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
106
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
61
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
34
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
101
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
99
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
35
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
59
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
219
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
19
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
17
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
2
answers
574
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
523
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
29
views
Magento Observer Dispatching
I am little bit confuse about Observer Dispatching. What it means by. Can Anybody expalins me.
0
votes
1
answer
383
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
29
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
196
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
224
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
52
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
2
answers
558
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
94
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
141
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
101
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 ...
1
vote
1
answer
39
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
544
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
246
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 "...
1
vote
1
answer
792
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 ...