Magento 2 Tips : Install external lib
How to install a excel lib to generate formatted excel file
Step 1) Go to the magento 2 root folder then execute following command
sudo -uwww-data composer require phpoffice/phpspreadsheet
Related cards:
Magento 2 Tips: main.WARNING: Session size of 257209 exceeded allowed session max size of 256000.
This can be fixed by excuting folloing configuration.
./bin/magento config:set system/security/max_session_size_admin 512000
./bin/magento config:set system/security/max_session_size_storefront 512000
Magento 2 : How to use Javascript in Magento
Javascript in Magento 2
Magento 2 uses Require JS lib and Knockout JS lib to solve the page speed and manage the JS dependency.
As JS are loaded asynchronously in backend, it helps to increase the page speed.
The JS files can be found in f...
Magento 2 : Admin Module Part 2
5.Create Model and Resource model
Address model class extends the AddressInterface and it contains the data object getters setter methods.
<?php
/**
* Address
*
* @copyright Copyright © 2021 Va...
Magento2 : Admin Module Part 3
This section contains the edit UI components and layout xml files
Stesps :
- Form ui components
create a file kpsaddress_index_lising.xml for grid under ui_component
<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http...
Magento 2 Tips : Date Format
use Magento\Framework\Intl\DateTimeFactory;
=====================================
$endDate = $this->dateTimeFactory
->create($milestone->getData('end_date'), new \DateTimeZone('UTC'))->format('d/m/Y');
==========================...
Magento 2 Tips : Conditionally Loading Javascript and css in layout xml
First create your conditions in the system.xml..
Second add your css and js in your local xml.
<reference name="head">
<action method="addCss" ifconfig="my_config_section/advanced/load_css"><stylesheet>css/my_module/my_module.css</st...
Magento 2 : Address additional attributes
In this example, you can learn how to add additional attributes for customer address
Steps
- Add additional attributes to EAV table
- Create extension attributes to link with models to save additional attributes values in databases
- Crea...
Magento 2 : Customer attribute creation
CustomerSetupFactory and Attribute SetFactory classes should be used to create the customer attribute using setup script
<?php
namespace ExamNotes\Chapter10\Setup;
use Magento\Customer\Setup\CustomerSetupFactory;
use Magento\Eav\Setup\Eav...
Magento 2 Tips : How to get client ip
The client ip can be retrieved using
getClientIp()
method in
Magento\Framework\HTTP\PhpEnvironment\Request
class. This is very useful , when do the ip restriction in maintenance page development.
Magento 2 Tips : System Configuration field dependent on multiple values
How to show a field dependent on another field multiple values
<depends>
<field id="vasan/general/enable">1</field>
<field id="vasan/email_dispatch/receiver" separator=",">2,3</field>
...