https://magento2.atlassian.net/wiki/display/m1wiki/Magento+1.x+Events+Reference The following is a list of many Magento Community Edition events with module and parameters. Note that some events are dispatched with dynamically-calculated names, so this list is and always will be “incomplete”. At the bottom there is example of using...
Category: magento 2
Declaring Observers in Magento 2.0 (Updated)
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...
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();
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...
Magento form setting controller and block
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 <?php class Excellence_Form_Block_Adminhtml_Form_Edit extends Mage_Adminhtml_Block_Widget_Form_Container { public function __construct() { parent::__construct(); $this->_objectId =...
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...