1/1/2024 0 Comments Simplenote tab functionMagelearn\SimpleNote\Block\Adminhtml\Order\View\Tab\SimpleNote We will also display customer's previous orders by adding new tab in left side of sales order view page.įor that, add app/code/Magelearn/SimpleNote/view/adminhtml/layout/sales_order_view.xml file. We will also display this simple_note field by adding a new tab in left side of sales order view page. Now, we will display this simple_note field at different places in Magento admin Sales > Order > View Page. 'Magelearn_SimpleNote/js/action/save-order-simple-note',įunction ($, ko, Component, saveOrderSimpleNote, quote) ) Īdd app/code/Magelearn/SimpleNote/view/adminhtml/ui_component/sales_order_grid.xml file. Magelearn_SimpleNote/js/view/isSimpleNoteĪs per defined in checkout_index_index.xml file,Īdd app/code/Magelearn/SimpleNote/view/frontend/web/js/view/order-simple-note.js file. Magelearn_SimpleNote/js/view/order-simple-note To add the simple note to the checkout and to show the field on the payment step:Īdd app/code/Magelearn/SimpleNote/view/frontend/layout/checkout_index_index.xml file. $order->setData(SchemaInformation::ATTRIBUTE_SIMPLE_NOTE, $simpleNote) $simpleNote = $quote->getData(SchemaInformation::ATTRIBUTE_SIMPLE_NOTE) $quote = $observer->getEvent()->getQuote() Īdd app/code/Magelearn/SimpleNote/Observer/AddSimpleNoteToOrderObserver.php file. Now we need to save the data from quote to the order.įor that we will Add the observer and declared the event:Īdd app/code/Magelearn/SimpleNote/etc/events.xml file. Throw new CouldNotSaveException(_('The simple note # number could not be saved')) $quote->setData(SchemaInformation::ATTRIBUTE_SIMPLE_NOTE, strip_tags($sn)) Throw new NoSuchEntityException(_('Cart %1 doesn\'t contain products', $cartId)) $quote = $this->quoteRepository->getActive($cartId) Return $this->setData(SchemaInformation::ATTRIBUTE_SIMPLE_NOTE, $simpleNote) Īdd app/code/Magelearn/SimpleNote/Model/SimpleNoteManagement.php file. _get(SchemaInformation::ATTRIBUTE_SIMPLE_NOTE) Now, we will Add Magento Web API classes to save the data:Īdd app/code/Magelearn/SimpleNote/Api/Data/SimpleNoteInterface.php file. We have added virtual type in the di.xml file. We have highlighted code in above file to save the data in the order grid table, but it is not required if you do not want to display the data in the admin order grid. Now, we will add di.xml file and define necessary nodes for simple_note field.Īdd app/code/Magelearn/SimpleNote/etc/di.xml file. Read more details about Magento webapi from here. In this post, we will do it by declaring the Magento WebAPI.Īdd app/code/Magelearn/SimpleNote/etc/webapi.xml file. $dataSetup->getTable('sales_order_grid'), Protected function addAttributeToOrderGrid($attributeCode, $attributeAttr, $dataSetup) $salesSetup->addAttribute('order', $attributeCode, $attributeAttr) $salesSetup = $this->salesSetupFactory->create( Protected function addAttributeToOrder($attributeCode, $attributeAttr, $dataSetup) ![]() $quoteSetup->addAttribute('quote', $attributeCode, $attributeAttr) $quoteSetup = $this->quoteSetupFactory->create( Protected function addAttributeToQuote($attributeCode, $attributeAttr, $dataSetup) SchemaInformation::ATTRIBUTE_SIMPLE_NOTE, Public function execute(ModuleDataSetupInterface $dataSetup) ![]() $this->addSimpleNoteFieldToQuoteAndOrderService->execute($setup) Īdd app/code/Magelearn/SimpleNote/Setup/SetupService/AddSimpleNoteFieldToQuoteAndOrderService.php file. Public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) We need to add the attributes to the quote and order entities.Īlso, to have an ability to see it on the order’s grid, we need to add the column in the sales_order_grid table.įor that, we will Add a setup script classes for adding the attribute to the tables:Īdd app/code/Magelearn/SimpleNote/Setup/SchemaInformation.php file: addSimpleNoteFieldToQuoteAndOrderService = $addSimpleNoteFieldToQuoteAndOrderService
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |