Skip to main content

All Questions

Filter by
Sorted by
Tagged with
1 vote
1 answer
72 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 ...
cereallarceny's user avatar
0 votes
1 answer
436 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 ...
kevkevdev's user avatar
0 votes
2 answers
266 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 ...
Arun Sharma's user avatar
  • 1,347
1 vote
1 answer
374 views

How can i get customer data after registration?

I have the following code but it is not working. vendorName/moduleName/etc/module.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
Diego Zaizar's user avatar
0 votes
0 answers
339 views

How to create custom payment module in magento 2?

I want to get payment request in Test\Testpayment\Gateway\Request Request.php namespace Test\Testpayment\Gateway\Request; use Magento\Payment\Gateway\ConfigInterface; use Magento\Payment\Gateway\...
Nitesh Kumar  Singh's user avatar
1 vote
2 answers
1k views

Redirect to login with add cart button for guest user

I'm trying to redirect guest users to the login page when they click on the Add to Cart button and they are not registered. But I can't do it. I am using an Observer with the following event <...
I. Munoz's user avatar
3 votes
3 answers
2k views

Magneto 2 How to call Helper function in observer file

I am new to Magento development and I am using a custom MySQL query in some places like in observer/plugin etc. These codes are repeating for all these files. so I want to make a new reusable ...
Sanjun Dev's user avatar
0 votes
2 answers
563 views

Magento 2 :- how to get email address in sales_quote_address_collect_totals_before events

How to get email address in sales_quote_address_collect_totals_before events guest user email address. <?php namespace xxxxxx\xxxx\Observer; use Magento\Framework\Event\ObserverInterface; ...
Nitesh Kumar  Singh's user avatar
0 votes
0 answers
95 views

how to get guest email address in CollectTotalsObserver page in magento 2

how to get a guest email address in CollectTotalsObserver page in Magento 2. public function execute(\Magento\Framework\Event\Observer $observer) { /** @var \Magento\Quote\Api\Data\...
Nitesh Kumar  Singh's user avatar
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 ...
Deggial's user avatar
  • 130
0 votes
0 answers
102 views

how to get the custom page event happened data to observer in magento 2?

I have custom module observer in Magento 2 <event name="controller_action_postdispatch_mpquotesystem_sellerquote_quoteedit"> <observer name="...
prabhakaran7's user avatar
  • 1,125
0 votes
3 answers
1k views

how i can override the observer of other modules in magento 2

how i can override observer of other module(custom module) to my another custom modules in magento 2 is it possible ??? Does anyone have an idea? ex : custom module 1: the observer for ...
prabhakaran7's user avatar
  • 1,125
0 votes
2 answers
1k views

How to print order details for event observer sales_order_save_after

want to print order details and product details (variants) which are ordered. My xml file <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
Nitesh Kumar  Singh's user avatar
2 votes
1 answer
1k views

Magento 2: How to stop event/observer if another already ran

I have 2 events running if subscribe to newsletter is checked on the checkout page. sales_model_service_quote_submit_success newsletter_subscriber_save_after Can i prevent event #2 from happening if ...
Kasper Morberg Bang's user avatar
1 vote
1 answer
448 views

I want to run an Event Observer once after my custom module is installed

Is there a way to run a function (to call an api) once after a module is installed? It could be during admin page load or in the install script. But i wish to run only once. Thanks
subhas's user avatar
  • 53
4 votes
2 answers
7k views

Magento2 : How to add Observer for catch when new order placed

I wanted to save the orders from magento2 to my local Database. I am planning to Create a module and add Observer to catch once a order is placed. I don't know much about the Events & observer, ...
JB Pakalapati's user avatar
0 votes
1 answer
99 views

Magento2 Event interception not working

I want to intercept sales_order_place_before event, so I created a new module named app\code\Giulio\CheckoutExtention, created aregistration.php` file where I put this code below: <?php \Magento\...
Giulio Savoca's user avatar
0 votes
1 answer
515 views

Magento 2 Programatically create a product on the checkout_cart_product_add_after event

I'm currently working on a module that adds specific products to the cart when the customer adds a normal product. I created an observer for the checkout_cart_product_add_after. The user will select a ...
Filcp's user avatar
  • 1
3 votes
1 answer
2k views

How to add default header and footer to a custom mail on magento 2.2

I have created a module where I send a custom mail. For this, I have a custom email template. Now what I want to do is to include the default header and footer that appears in all my Magento emails, ...
Alin Lupoiu's user avatar
  • 2,682
4 votes
1 answer
1k views

Magento2 - Creating my first custom module and observer

this is my first project with Magento and my first question here. I'm trying to create an Observer, but I can't figure it out. The error in var/log/system.log is: main.CRITICAL: Exception message: ...
Cosmin's user avatar
  • 45
1 vote
0 answers
385 views

How to Hide Add to cart button in Magento 2 front end without editing phtml file

I created a custom module which has option to enable / disable Add to cart button in front end , I'm trying to hide button without editing the core templates files , is there any way to implement it . ...
Manohar singh's user avatar
1 vote
1 answer
952 views

Magento2 Why I can't get POST data from .\Magento\Framework\App\RequestInterface $request?

This is my code in my module observer namespace Customtest\Customlogin\Observer; use \Magento\Framework\Event\Observer; use \Magento\Framework\Event\ObserverInterface; class CustomerLogin ...
stevieki's user avatar
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 ...
Slimshadddyyy's user avatar
1 vote
1 answer
787 views

Is there any observer like 'cataloginventory_stock_item_save_commit_after' in magento 2?

I need to trigger the inventory changes in Magento 2.0 I have an observer cataloginventory_stock_item_save_commit_after in Magento 1.9 and its working fine. But I can't find the same observer in ...
Adarsh Ediyottil's user avatar
2 votes
3 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 ?
Jsparo30's user avatar
  • 1,356
1 vote
2 answers
8k views

How to change the price in quote while adding product to cart?

I want to apply a custom price for the current order. I read that I should use sales_quote_add_item, But its looks like I am doing something wrong. I found some tutorials for magento1 but not for ...
Rahul Chaurasia's user avatar
0 votes
1 answer
2k views

Magento 2: Can we call one observer in another observer?

I already have 1 observer on checkout_cart_product_add_after . Before end of $this I woule like to call another observer which is located in different module magento\app\code\Custom\Module\Observer\...
Jackson's user avatar
  • 9,969
1 vote
2 answers
837 views

Custom module, checking variable in observer

I'm new in making modules, considering below code wondering how would be possible to verify if the checkbox has been selected: my observer.php: public function execute(\Magento\Framework\Event\...
Zinat's user avatar
  • 2,079
4 votes
1 answer
10k views

Magento 2: Check condition on Click of "Proceed to Checkout"

May be I need to create Event Observer. I would like to check Product's Type Condition & Display Message Accordingly on Shopping Cart Page. <event name="...
Jackson's user avatar
  • 9,969
2 votes
1 answer
399 views

Got fatal error while run this

I am newbie in Magento 2 and i created an event and observer I got fatal error Fatal error: Call to a member function getAllVisibleItems() on null here is my events.xml <?xml version='1....
Ramkishan Suthar's user avatar
1 vote
1 answer
3k views

Magento2 Observer - Order Complete

What event would I want to observe for when an order is set to 'complete' in the back end?
ol'bob dole's user avatar
2 votes
1 answer
955 views

Magento 2 custom notifications

am trying to insert custom notifications into adminnotification_inbox table as per core module Magento-AdminNotifications approache but am't able to insert custom notifications. Code is in below ...
Ramesh's user avatar
  • 986
1 vote
1 answer
257 views

Adding default address(shipping) to when customer signup

I'm new to Magento 2, no e-commerce experience before. So I'm working on making this module that should 'add default shipping address to customer when they sign up'. During some research and ...
medi86's user avatar
  • 33
14 votes
4 answers
3k views

When to dispatch events in a custom module?

This is a question regarding both Magento 1 and Magento 2. I understand that, as a good practice, 3rd party modules developers are encouraged to dispatch events in their custom module to make it ...
Raphael at Digital Pianism's user avatar
0 votes
1 answer
3k views

magento 2 unable to redirect to external url from observer

I made modules that work fine but unable to redirect to another url when event fired what code does when adding to cart is pressed I want to redirect to other URL say google.com my module works as a ...
mcoder's user avatar
  • 713
9 votes
3 answers
2k views

Magento 2: Which extension mechanism to choose?

We can extend controller in two ways: using preference and using plugin. But I do not understand that, which one is good and advantages/disadvantages of preference vs plugin. <preference for="...
Anand Ontigeri's user avatar
3 votes
3 answers
109 views

Is it possible to execute code for every fired event without too much boilerplate code?

This is mostly out of curiousity, as I think it would be very useful in some situations. Is there are a way in Magento to execute a piece of code every time an event is fired, regardless of the event? ...
Thierry's user avatar
  • 133