Year: 2016

magento 2

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...

magento 2

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 2

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();

Knockout js

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() {...

Knockout js

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:...