New answers tagged

1

The first thing i noticed in your code is that the block type is not core/messages for the 'global_messages' (reference is app/design/frontend/base/default/layout/page.xml where the 'global_messages' block is defined). However, if you check the app/code/core/Mage/Core/Block/Messages.php class, you will see that this block doesn't use a template file, it is ...


0

You can change the price using custom price method like: $newPrice = ''; $item->setCustomPrice($newPrice); $item->setOriginalCustomPrice($newPrice); $item->getProduct()->setIsSuperMode(true); $item->save(); and update all totals that you have: $quote->collectTotals() It is not a good idea to update only subTotals or grand totals because ...


1

Yes , i have found a way for it. Please follow below steps to achieve this. Step 1: Create events.xml file under path PackageName/Module/etc/ <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> <event ...


0

Update change the events.xml area from global to webapi_rest use app/code/Nadine/Campaign/etc/webapi_rest/events.xml instead of app/code/Nadine/Campaign/etc/events.xml It will work Better observe the event checkout_onepage_controller_success_action, in case if you want to observe the store front order placement and use one page checkout <?xml version=&...


0

Update Its better to write your own Module instead of overriding Magento modules. So just add a module Vendor_Module and add a helper class as given below <?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Vendor\Module\Helper; /** * Sales module base helper */ class Reorder extends \...


0

Use the sales_model_service_quote_submit_success event. vendor/magento/module-quote/Model/QuoteManagement::submitQuote dispatches the sales_model_service_quote_submit_success after OrderService place() which saves the order and creates the ID.


0

I would suggest you take the customer ID from session. In the same observer class, inject Magento\Customer\Model\Session into the constructor and save it in a private property, say $session and use it like this: $this->session->getCustomerId() Sidenotes you don't need to initialize the order object in the constructor in your above code your observer'...


-2

The question here is which approach to be used Plugins or events & Observers pattern. When to use ? plugins and observers both can be used to run our custom script after certain Magento 2 - events or public methods are executed. Which one to use ? When we need to modify Magento core functionality (Ex: adding additional data to order collection object) ...


0

if you want to made these changes after order submit better you use this event <event name="sales_order_place_after"> <observer name="order_create_observer" instance="Example\Details\Observer\OrderCreateObserver" / > </event> instead of <event name="checkout_submit_all_after"> <...


0

I based my code on the previous answers: <?php namespace {Vendor}\{Module}\{the_path_you_decide}; class IndexerManager { private \Psr\Log\LoggerInterface $logger; private \Magento\Indexer\Model\IndexerFactory $indexerFactory; private \Magento\Indexer\Model\Indexer\CollectionFactory $indexerCollectionFactory; public function __construct(...


0

Reference Link create events.xml file at path companyname/modulename/etc/adminhtml/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="order_cancel_after"> &...


0

Old question, and posted answer is valid for sure Just wanted to point that the mentioned event (sales_quote_add_item) in question is available in Magento2, and it works fine for the asked customization with very few code public function execute(\Magento\Framework\Event\Observer $observer) { // your logic to get $yourPrice $quoteItem = $observer->...


0

$logger->info(json_encode($orderData)); You should encode to JSON the objects or arrays.


0

You can try adding an observer on the customer_register_success event, which is dispatched in vendor/magento/module-customer/Controller/Account/CreatePost.php, right after the customer account was created.


1

protected $_eventManager; public function __construct( \Magento\Framework\Event\ManagerInterface $eventManager, ) { $this->_eventManager = $eventManager; } public function execute() { //you can pass param value and set condition here as per your requirement. $this->_eventManager->dispatch( 'customer_login_observer',...


0

try create event:- path:- Vendor/Module/etc/frontend/events.xml <?xml version="1.0" encoding="UTF-8"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> <event name="catalog_product_collection_load_after&...


0

So I found the solution of my question and got it working. I am posting my code as an answer if anyone wants it. What I was trying to do is remove all the disables products from my reorder and add rest of the products in the cart. Store desired information in Customer session and if our reorder contains disabled products the display a message in the cart ...


Top 50 recent answers are included