Registration and creation of observers in Magento 2.x is a bit different from the version 1.x. a separate events.xml file is used for registering observers; the scope of the observer is defined not by the xml node, but by the...
Year: 2016
Magento 2 upgradeschema script
<?php namespace MagePal\TestDiscount\Setup; use Magento\Framework\Setup\UpgradeSchemaInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\SchemaSetupInterface; class UpgradeSchema implements UpgradeSchemaInterface { public function upgrade(SchemaSetupInterface $setup,ModuleContextInterface $context){ $setup->startSetup(); if (version_compare($context->getVersion(), '1.0.2') < 0||version_compare($context->getVersion(), '1.0.3') < 0||version_compare($context->getVersion(), '1.0.4') < 0 ||version_compare($context->getVersion(), '1.0.5') < 0 ) { // Get module...
Set custom attribute value on cart page
In Magento 1.x I have created following function in Namespace/Modulename/Model/Observer.php public function salesQuoteItemSetCustomAttribute($observer){ $quoteItem = $observer->getQuoteItem(); $product = $observer->getProduct(); $quoteItem->setCustomerProductPoints($product->getCustomerProductPoints()); } Called this function in Namespace/Modulename/etc/config.xml <sales_quote_item_set_product> <observers> <product_point_quote> <class>productpoint/observer</class> <method>salesQuoteItemSetCustomAttribute</method> </product_point_quote> </observers> </sales_quote_item_set_product> Also Have converted my custom attribute...
magento objectManager command (Memeroy)
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $customer_object = $objectManager->create('Magento\Customer\Model\Customer');
Magenot 2 customer custom attribute not add in frontend but can add in admin (resolved)
You must use customer factory and updateDate to update the custom value $customer = $this->customerFactory->create(); $customerData = $this->customer->getDataModel(); $customerData->setCustomAttribute('cuser_id', 'testnew1235'); $customer->updateData($customerData); $customer->setData('email',"abcd123t@gmail.com"); $customer->setFirstname("First Nametestdfdf"); $customer->setLastname("Last namesdfadsf"); $customer->setPassword("test1123"); $customer->save();
Magento force update Quote totals
You can add custom calcule in total module but it can't recalcul when you not force recalcul in certain step so you can use => to force reload total $this->_objectManager->get('\Magento\Checkout\Model\Session')->setCartWasUpdated(false)->loadCustomerQuote();
2. Computed Observables
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script type='text/javascript' src='knockout-3.4.0.js'></script> </head> <body> The first name is <span data-bind="text: firstName"></span><br/> The last name is <span data-bind="text: lastName"></span><br/> The funll name is <span data-bind="text: fullName"></span><br/> </body> </html> <script> function AppViewModel() {...
1. Basic viewmodel and observableArray
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script type='text/javascript' src='knockout-3.4.0.js'></script> </head> <body> The name is <span data-bind="text: personName"></span> The age is <span data-bind="text: personAge"></span> The funll name is <span data-bind="text: fullName"></span> </body> </html> <script> var myViewModel = { personName:...
Advanced Permissions(Magento extension)
Why Use Advanced Permissions Assign sub-admins to local Store Views (English, German, etc.) Let marketers create one-off specials or set seasonal prices. Provide access to Reports and other data ensuring employees don't tamper with vital Magento settings, and much more....
MagMagento 2: Add new Custom Form Validation
FacebookTwitterGoogle+LinkedInPartager In Magento 1, There was one file validation.js. We can add the new validation on that file or also add in our extension .phtml or .js file. In Magento 2, We can add our custom validation in .phtml...