Questions tagged [event-observer]
Event/observer is used to work dynamically with Magento without altering the core code.
2,153
questions
1
vote
1
answer
3k
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 ...
0
votes
1
answer
2k
views
Observer for Admin while creating an order
Is it possible to have an observer while making an order in the admin panel?
I'm trying to change the 'purchased from' depending on which customer group the customer is in. So if a customer is in ...
0
votes
2
answers
3k
views
Magento 2 - Get Cart Total in Observer
I needed to get the cart total in my observer.
Here is the code I have:
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Psr\Log\LoggerInterface;
class ...
1
vote
1
answer
1k
views
Magento 2: I need to run observer function through Cron job
I want to run an observer function through a Cron job. Can anyone share the simple observer function.?
Here is my code
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
1
vote
1
answer
1k
views
Magento 2: Rest API "Checkout Cart Product Add After" event is not working
I have faced issue in checkout_cart_product_add_after event using add to cart rest API.
Same add to cart event is working in website. But it is not working in Add to cart rest API.
Add to cart API ...
1
vote
1
answer
2k
views
Magento 2 - Prevent form submit on page reload when Product add from sample script to Magento Shopping Cart
Below sample PHP script will list simple/configurable product with add to cart button. When user clicks on submit button, it will redirect to Magento shopping cart page and selected product will be ...
3
votes
2
answers
1k
views
How to create observer to change order status after it was created?
I am creating a custom payment method.
Before calling the payment gateway, I am calling PlaceOrderAction javascript function in mypay-method.js. that way, order is created in Processing status.
...
3
votes
1
answer
4k
views
How to get quote item id in checkout_cart_product_add_after observer in magento2
I have setting the custom price of the product on adding to cart which I am doing through some observer .
Everything is working fine except I am not getting the item id in the observer.I tried ...
1
vote
1
answer
2k
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
1
answer
28
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
1
answer
1k
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
1
answer
1k
views
Restrict access to pages for non logged users
I need to restrict access to all pages except / customers, contacts and home page.
My code is not working.
<?php
use Magento\Customer\Model\Context;
use Magento\Framework\Event\Observer;
use ...
0
votes
0
answers
15
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 ...
0
votes
1
answer
34
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/...
17
votes
4
answers
2k
views
Is there an event or plugin spot for when cart rule is no longer valid?
Is there an event or place I can plugin for when a shopping cart price rule is no longer valid (such as when it expires or if you change the quantity of other products where it no longer applies)? I ...
0
votes
1
answer
313
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
1
vote
3
answers
2k
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/...
2
votes
1
answer
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
2
answers
5k
views
Remove and recreate custom option programatically on product before save event
I m creating a custom option programmatically using observer with the catalog_product_save_before event.The custom option was created successfully on product save. but the problem is whenever the ...
0
votes
2
answers
2k
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
2
answers
1k
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 ...
4
votes
3
answers
2k
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
1
answer
3k
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/...
1
vote
1
answer
1k
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
1
answer
2k
views
how to get customer group id from last order id in magento 2
I want to change customer group after placing an order so I need Customer Group id which can be update in observer . How to achieve it?
0
votes
0
answers
19
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.
0
votes
1
answer
935
views
How to change the price of a product on the category page?
I am building a module for customer specific pricing. Here is psuedocode for altering the price for a specific product. This works on the product page and through the checkout journey.
$_product = $...
1
vote
0
answers
28
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=&...
4
votes
1
answer
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 ...
0
votes
1
answer
2k
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
1
answer
29
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
26
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 ...
5
votes
1
answer
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
4
answers
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 ...
2
votes
1
answer
2k
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
1
answer
2k
views
Newsletter subscribe/unsubscribe email notification event observer
I am writing my own admin email notifications module.
So far it has New Order and Low Stock observers set up and working just fine.
I want to add the Newsletter subscribe/unsubscribe observer to it ...
0
votes
3
answers
2k
views
How can i catch customer_save_after_data_object after saving account information in frontend?
How can i catch customer_save_after_data_object
after saving account information in frontend?
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 ...
4
votes
1
answer
2k
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/...
2
votes
3
answers
6k
views
How to get quote Id using sales_quote_collect_totals_after events
I have create a programmatically order. But when submit order sales_quote_collect_totals_after events fire before save collect totals.
Here is my code :
$storeId = Mage::app()->getStore()->...
0
votes
3
answers
2k
views
How to get updated cart subtotal in checkout_cart_product_add_after event observer in Magento 2?
I want to add a free product to cart with another product. For that I wrote checkout_cart_product_add_after event observer. My problem is, I don't get the updated cart subtotal(after adding first ...
0
votes
1
answer
1k
views
How to get order data from sales_order_shipment_save_after event
I am using sales_order_shipment_save_after event events for update update order status after shipment.
namespace Tenx\SalesExt\Observer;
use Magento\Framework\Event\ObserverInterface;
/**
* Webkul ...
1
vote
1
answer
2k
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, ...
0
votes
2
answers
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::...
2
votes
2
answers
2k
views
How to call an observer from custom module: Magento 2
I built a custom module which has a custom observer OrderSaveAfter.php. How can I call any function inside the custom observer from another custom code ?
1
vote
1
answer
3k
views
How to update subtotal after changing price with observer
I am using an observer to change bundle product price. I have tried events 'checkout_cart_product_add_after' and 'checkout_cart_save_after'. Both events update the product's price but the subtotal ...
0
votes
1
answer
1k
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 ...
1
vote
1
answer
2k
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
2
answers
1k
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 ...
1
vote
4
answers
3k
views
Magento2 Event Observer Redirect Simple Product to Configurable Product
I'm trying to write a module to redirect simple products to their configurable products once each simple product is clicked on. I've done a bit research and wrote an Observer to catch event: ...