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
0answers
11 views

Magento 2 - How to get post parameters in observer?

In Magento 2 I have add a custom checkbox in cart page. I managed to add this checkbox in this file : app/design/frontend/[Vendor]/[Module]/Magento_Checkout/templates/cart/form.phtml And I need to get ...
1
vote
3answers
52 views

What event should i trigger that works when a customer places an order?

I'm new to Magento and the next step I want to learn is to listen to an event. So, I'm trying to find which event should I trigger that works after a customer has placed an order that also carries ...
0
votes
3answers
44 views
+50

Add JS on condition

I'm want to add a dynamic js remote file in my website. So far, I've added CSS file thanks to this, but I can't achieve to add CSS files. I've an observer with that. <event name="...
0
votes
0answers
25 views

Magento 2 Available Qty Check Before Taking Customers to Payment Gateway

When customer tried to place an order , In my website i have only one Qty for each SKU. When two different customers tried to place an order on same time for same SKU one customer got an order number ...
0
votes
1answer
13 views

Magento 2 coupon apply and remove event

I want to redirect to /checkout if a coupon is applied and it is valid. I have tried this event controller_action_predispatch_checkout_cart_couponPost this only works on coupon cancel and /cart page. ...
0
votes
2answers
20 views

Using the right event observer name issue in the admin area

I would like to some custom things when you are on the create a new website in the admin area page. This is the exact controller used to render that page: \Magento\Backend\Controller\Adminhtml\System\...
0
votes
2answers
16 views

Unable to save product attribute issue

I have an observer, using this event: catalog_product_save_after , where I would like to assign some website ids to my product. This is my code: public function execute(Observer $observer) { $...
0
votes
1answer
16 views

How to set custom_field value from product page to quote after a product added to cart in magento 2?

I have a custom_field on the product details page( Like a hidden field ). Which is not a product attribute. I can get this field value using checkout_cart_product_add_after event using an observer ...
0
votes
0answers
15 views

How to execute javascript function after a product is added to cart?

I'm trying to configure Sendinblue Automation to work with Magento 2. In order to do that, I have to execute some Javascript functions after some Magento events like: After a product is added to cart....
1
vote
1answer
14 views

Magento 2 - cant modify quote before placing order

I try to delete all items with a custom product type from the quote before the order is placed. So I created an observer for the event sales_order_place_before. In this observer I am collection all ...
-1
votes
2answers
37 views

Magento 2 - Can you replace any observer with plugin?

I am using a observer for the event sales_order_place_before. It does not work as expected, so I try to replace it with a plugin to see if it does make a difference. The event sales_order_place_before ...
0
votes
0answers
21 views

Magento 2 getFullActionName() not working when FPC is enabled

I have an observer subscribed to controller_front_send_response_before event. in the observer i'm trying to call the page type by getFullActionName() method. But when the magento FPC is enabled, its ...
0
votes
2answers
20 views

Magento 2 - event is not getting triggered - observer not working

This is my code. The event is not getting triggerd after I place a new order. app/code/Company/RalSurcharge/etc/frontend/events.xml (i also tried app/code/Company/RalSurcharge/etc/events.xml) <?xml ...
0
votes
0answers
35 views

How to execute javascript code and pass to it some values after an event is triggered?

I'm trying to execute some javascript code and pass to it some values after an event (e.g. Add to Cart event) is triggered. To be more specific I'd like to pass: All logged customer details (...
0
votes
0answers
9 views

Magento 1.9 payment_method_is_active event obsserver is not seeing my new payment method

I installed a new payment method and want to hide it for some customers using an observer. The observer is not seeing the payment method, any ideas why it wouldn't? In my observer, I log all the ...
0
votes
0answers
11 views

Source code is empty in shipment observer magento2

I am trying to get source_code from the shipment_id Have used below event. Vendor/Module/etc/events.xml <event name="sales_order_shipment_save_after"> <observer name="...
0
votes
0answers
13 views

How to integrate Sendinblue Automation with Magento 2?

I'm trying to integrate Sendinblue Automation with Magento 2.4.1. In order to do that, I'm following the official docs that basically says this: Install the Javascript tracker by placing the ...
0
votes
1answer
36 views

Get shipping address county in Magento 2 observer

Hi I have a custom module . I want to get shipping country inside public function execute(\Magento\Framework\Event\Observer $observer) { Please let me know how can i get this? I have seen this ...
0
votes
0answers
12 views

Ideal place for checking quote and change it

After the user adds a product to the cart, I need to run a check on the quote because I have to manipulate the total price if necessary and then save the changed quote. Where is the ideal place to ...
0
votes
2answers
31 views

Magento 1.9 - Observer condition not working for Guest Customer

My condition: Selected Payment Gateway Eligible only for a selected customer group, id 9. My observer: <?php class Gta_FilterPaymentGateway_Model_Observer { public function paymenter(...
0
votes
3answers
27 views

Magento 2.3 - Getting website id in the Observer

My observer : <?php namespace Gta\EnablePaymentMethod\Observer; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; class PaymentMethodEnable implements ...
0
votes
1answer
224 views

send Observer data to phtml file in Magento 2

I am trying to send Observer info into the block file. used the add to cart event as like below. app/code/Vendor/Module/etc/events.xml <?xml version="1.0"?> <config xmlns:xsi="...
0
votes
1answer
29 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 don`n work <?php use Magento\Customer\Model\Context; use Magento\Framework\Event\Observer; use ...
0
votes
1answer
31 views

Where can I get all observers(events) of current page?

Where in the code magento2 trigger one by one all events of observers. I want to debug it by xdebug and find all events that can be on that page.
0
votes
0answers
21 views

In custom mail getTemplateVars returs null

I'm using checkout_onepage_controller_success_action event to trigger my custom mail based on my requirement.I already added my email template variables using email_order_set_template_vars_before ...
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
34 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
2answers
28 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 ...
0
votes
2answers
22 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
16 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
21 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->...
1
vote
1answer
209 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
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
40 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 ...
0
votes
0answers
14 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
26 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
1answer
47 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 ...
-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=&...
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?
0
votes
1answer
20 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()->...
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', [...
2
votes
3answers
87 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(...
0
votes
1answer
21 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
0answers
11 views

Get the 'password' Value from AJAX Login Magento2 in the event customer_login

I need to login to another website with the same credentials when the customer_login event fired but with this code public function execute(\Magento\Framework\Event\Observer $observer) { $...
0
votes
1answer
22 views

Magento 2: Product attribute is not get any value in observer

Here am using if condition to redirect if product attribute option value is !5431 but attribute is not echo any value here. <?php namespace Softadroit\Prescription\Observer; use Magento\Framework\...
0
votes
0answers
24 views

Magento 2 : Is there a event which fires before every controller begins execution?

The best event I could get was the good old controller_action_predispatch but it fires after the controller is done execution and before layout generation. Any other event that works in frontend area ...
0
votes
0answers
38 views

How to save custom attribute in quote_item using api / rest

I'm creating a module where I add a new field in the quote_item and order_item table (not necessary in the product). The columns were created, and when I look at the items in the cart, I fear the ...
0
votes
2answers
55 views

Magento 2: Redirect custom attribute option to cms page url in obsever

How to redirect if custom attribute option value != 5431 to cms page else redirect to module Controller (prescription/index). Till now both conditions redirecting to module Controller <?php ...
0
votes
1answer
20 views

Magento 2: How to redirect to different urls using if else conditon in Observer

This is my observer code: <?php namespace Softadroit\Prescription\Observer; use Magento\Framework\Event\ObserverInterface; use Psr\Log\LoggerInterface; class Orderplaceafter implements ...

1
2 3 4 5
40