Category: magento 2

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

magento 2

Layouts and forms on Magento 2 admin

http://www.maximehuran.fr/en/layouts-and-forms-on-magento-2-admin/ We have to create a layout before create the form : app/code/Maxime/Jobs/view/adminhtml/layout/jobs_department_edit.xml Put this little content : <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <update handle="editor"/> <body> <referenceContainer name="content"> <block class="MaximeJobsBlockAdminhtmlDepartmentEdit" name="jobs_department_edit"/> </referenceContainer> </body> </page> We define a block inside, so...