New answers tagged

0

Use this code to redirect protected $_response; protected $storeManager; public function __construct( ................................... ................................... \Magento\Framework\App\ResponseInterface $response, \Magento\Store\Model\StoreManagerInterface $storeManager, ................................... ..........


2

I don't think it's related to customer being logged in or not, but I think order items are not persisted yet, as you're retrieving new order object. Also you should never use objectManager directly. Try updating your code to this: public function execute(\Magento\Framework\Event\Observer $observer){ $order = $observer->getEvent()->getOrder(); $...


0

Magento use 3 areas to manage events : Under etc/ folder for the both admin and frontend. Under etc/frontend folder for frontend area. Under etc/adminhtml folder for admin area. So if you are using an admin event only, you should use etc/adminhtml/events.xml and not etc/backend/events.xml as you did


-1

Kindly run php bin/magento setup:upgrade command and then php bin/magento s:s:d command then it should work fine. or you may refer to this question https://stackoverflow.com/questions/52081048/magento-1-9-magelog-isnt-creating-the-log-files


0

There was a code breaking change Read https://github.com/OpenMage/magento-lts/issues/882 And apply https://github.com/OpenMage/magento-lts/pull/887 Please mark as the answer if correct


2

Change your event file name with events.xml app/code/Vendor/Module/etc/events.xml Clear cache and check it.


0

You have to declare your observer in the appropriate scope. Also make sure that it is named events.xml. Frontend: Put your events.xml to <module-dir>/etc/frontend/events.xml since this is a frontend event. Backend: For backend events put it in <module-dir>/etc/adminhtml/events.xml Documentation


2

You need to update your observer function's code : public function execute(\Magento\Framework\Event\Observer $observer) { $_product = $observer->getEvent()->getProduct(); $_sku = $_product->getSku(); $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/Rohan.log'); $logger = new \Zend\Log\Logger(); $...


0

You can try the following code to achieve your requirement: Use the below for events.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> <event name="checkout_cart_product_add_after"> <observer name="...


0

Here is the method \Magento\Quote\Model\QuoteManagement::submitQuote where the sales_model_service_quote_submit_before is dispatched. A text search through the code directory with the event name would have given you what is needed.


2

Replace this below code in your observer file code and check it : public function execute(Observer $observer) { $order=$observer->getEvent()->getOrder(); $order->setData('reward_point',0); $order->save(); return $this; }


1

You can use the below code to send an email. $body = "Your Response"; $emailTemplate = Mage::getModel('core/email'); $emailTemplate->setFromName('Your Store Name'); $emailTemplate->setBody($body); $emailTemplate->setSubject("Custom Email from observer"); $emailTemplate->setType('html'); $emailTemplate->setToEmail('testing@example.com'); $...


3

You can try below code. <?php class Gta_MerchantNotification_Model_Observer { public function merchantremainder($Observer) { $order = $Observer->getEvent()->getOrder(); $order_details = $order->getAllVisibleItems(); foreach ($order_details as $list) { $incrementid = $order->getIncrementId(); ...


4

i have get the reference URL for your solution... please look at this https://magecomp.com/blog/send-email-to-admin-after-customer-registration-magento-2/ in Your Observer you need to replace setTemplateVars(['post' => $postObject]) with setTemplateVars(['customer' => $postObject]) for send the customer name and email Id to mail. Let me know ...


Top 50 recent answers are included