Magento 2
When
you install the Magento 2 then visit 1st Dashboard
1st
You will see this structure
This
is landing page.
• When you will be login admin panel
then you visit Dashboard.
• Then you will run these command
then your project is running smoothly.
•
Go
to Magento root directory run command.
php bin/magento cache:clean
php bin/magento cache:flush
3. ENABLE
MAGENTO 2 CACHE
In order to Enable
Cache, you need to follow these instructions:
• Go to System
• Access Cache Management
• Enable the required cache types
After these steps visit next tab option
“STORES”
Stores:
This store has multiple option which is
given below.
•
Setting
•
Currency
•
Inventory
•
Attributes
•
Taxes
1.Setting: you can set your site by one clicks like which country sell your
product, location, store name, url, set base url, default pages, layouts,
cookies setting, session validation, currency setup by api, contact, content
management, google map api setting, default column grid, product fields auto
generation, storefront, product review, product alerts run settings, product
image placeholder, video, price, catalog search, search engine optimization,
category top navigation, downloadable product option, date time customer
option, security customer , sales yotpo ,account ,chart ,services etc.
Setting has main 4
categories.
1.All Stores 2. Configuration 3. Term
& Conditions
4.Order Status
1.All Stores: if
you visit then you will see this dialog box.
It is very simple if you want to add your
website store different url then you can set your website here.
2. Configuration: This is very important part of Magento you can set your website
here 60%. So it is very important and multiple tools are here so learn very
carefully.
You can set your website
frontend, seo, price, product listing many more.
We can understand very
easily way. Simple steps, don’t take hyperness.
This is Configuration
dialog box. You can see this pick.
We discuss all steps of
configuration because it is very important.
You will see 9 tab in
configuration image. We discuss step by step.
General: General
is a tab of configuration. You can understand by this pick.
General
has 5 steps
1.Country Options
2.State Options
3.Local Options
4.Store Information
5.Single-Store Mode
We
explain all general steps.
• Country Options:
you can set you country according to your product. If you want to
sell some country then you can set by country like, USA, India, UAE, Austria,
New zee land, etc. if you want to sell all product word wide then you can
select all country.
•
State
Option: Like country option. You can select you state
according to your need.
•
Local
Option: you can set your local zone.
•
Store
Information: you can save your store information like name,
phone number, country, zip-code, address etc.
Don’t use last step because when you have multiple
store then you will use.
Web
has 9 steps
1.Url Options
2. Search Engine Optimization
3.Base Urls
4.Base Url Secure
5.Default Page
6.Default Layouts
7.Default Cookies Setting
8.Session Validation Settings
9.Browser Capabilities Detection
We
explain all Web steps.
Q. When
Category not show in frontend
php
bin/magento indexer:reindex
php bin/magento cache:clean
php bin/magento cache:flush
base url
refresh after show the category.
Q. Theme
Installation & Setup
1. Open xampp & open-shell then copy your
theme only two file
1. App ->
root (folder-name)
2. bin
Open shell and paste it
php
bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
php bin/magento cache:clean
Q. After
installation your css and js not working
Use this command
then your css & js work…
php bin/magento setup:static-content:deploy -f
Q. The
stock item was unable to be saved
1st.
you check your elastic search are running or not if not running then your
product will not be save and no any updation.
Magento Add Store Information
How to create tax rule?
•
If you want
to create tax then flow these rule
1. Tax Rate
2. Customer Tax Class
3. Product Tax Class
Tax rate : according to country or state tax %.
Customer Tax Class: According to Whole Seller or Retailer
Product Tax Class : According to Goods
Currency Setup , Rate and Simbols
Here two steps currency setup
1st.
Stores:
Configuration
->General
->Web
->Currency page
2nd
Stores :
->Currency rate
->Currency Simbol
You can set
rate of currency for exp.
$USD = 1
INR = 74 A$ = 1.4
If you has not
any rate key or you have not buy any rate changer software like fix , yahoo
etc.
Then you
can change the rate according country,
Let’s
start. You have 1 product Rs.300 and you want to sell in USA then how to fix
the rate then you will use currency setup.
So like you
can fix your rate according to country.
You can understand by image.
Here are
two image 1st One dollar is equal to indian Rs. 75.27 and
2nd
is $1 = Australian Dollar rate: 53.24
But our
product amount is fix INR Rupees.
Or
Here you
can easily understand $1 rate is Aud = INR = USD .
Product sell in india
Product sell in USA with out tax.
Product Sell in Australia with tax.
Here You
can calculate by rate 74.8000
A$ = 1.4
$ = 1
I hope you should
be learn very easily.
Setup and Configuration of Payment Method
Stores:
Configuration
-> Sale
-> Payment Method
->Payment page
You can set
here payment method and priority of which method will be show 1st .
Like :
Amazone, Google pay, Razorpay, COD, etc.
Q. Setup
and Configuration of Shipping Method
Q. Setup
Multi Stores?
1. 1st We create a category Exmp.
“Grocery”
2. Then visit store menu
and click All Stores
3. After Open a page of
Store
You
will see three steps
1.
Create Store View
2.
Create store
3.
Create Website
Then
you will click create store
And
make store according to your category “Grocery”
You
can understand by this image.
After
create you store then show this type of page
Then you will
create “create store view “ page…
When you will click
the button then open a page like this.. you can check image
Here you will
select your root category 1st then fill according to your store…
You can check image
…
Then visit
store->Configuration
Open Configuration
page
Then Go to general
tab and click web tab it is very important.
You will see under
url options NO then you should Yes. Here is completed your task.
Your multistore is
created…
Run command
php bin/magento indexer:reindex
Then Open the frontend and reload then you will see in bottom check
the images..
You will see the grocery in bottom menu.
Q. Change Multistore theme or Set
Multi Store Theme
1. Create Custom Theme in
Magento 2
Theme Development Tutorial Step by Step
1st. you visit this path app/design/frontend/
Then you will create a folder ex. Training
Then you will create new folder “default” name under training with small
word
Ex. Default or you can change folder name according to you.
Like this
app/design/frontend/Training/default
then you create a theme.xml file
So your app/design/frontend/mageplaza/theme.xml
file
should look something like this:
Then past this code in theme.xml file
<theme
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../lib/internal/Magento/Framework/Config/etc/theme.xsd">
<title>Training
Default</title>
<parent>Magento/luma</parent>
</theme>
Theme structure
Theme Folder structure
app/design/frontend/
Training/
├── default/
│ ├── etc/
│ │ ├── view.xml
│ ├── web/
│ │ ├── images
│ │ │ ├── logo.svg
│ ├── registration.php
│ ├── theme.xml
│ ├── composer.json
<Vendor>
is
theme vendor. e.g: Training
<theme>
is
theme name. e.g: default
Then create registration.php file and paste this code.
<?php
/**
* Copyright © Magento,
Inc. All rights reserved.
* See COPYING.txt for
license details.
*/
use Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(ComponentRegistrar::THEME,
'frontend/Training/default', __DIR__);
Run Command:
php bin/magento
setup:upgrade
php bin/magento
setup:static-content:deploy –f
Then check database Table Name “theme”
if your theme name is show means your theme is correctly
install
Then visit magneto 2 home page and login your portal
Visit
content->configuration then open a dialog box and click the default theme
and change the theme
Thanks
Remove sample data modules
php bin/magento sampledata:remove
2. Create Custom Theme in
Magento 2
Theme Development Tutorial Step by Step
1st create a folder under app/design/frontend
Ex. Coderfunda
Then create next folder under Coderfunda you can choose name
Ex. funda
Create two file under funda
1.
registration.php
2.
theme.xml
Then past under registration file given code down …
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(ComponentRegistrar::THEME, 'frontend/Coderfunda/simple', __DIR__);
Then past under theme.xml file given code down …
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
<title> Coderfunda VS Luma</title> <!-- your theme's name -->
<parent>Magento/luma</parent> <!-- the parent theme, in case your theme inherits from an
existing theme -->
</theme>
Change the name according your folder name and note the small
word or capson word
ComponentRegistrar::register(ComponentRegistrar::THEME, 'frontend/Training/default', __DIR__);
Training/default'
change according to your project name means
Coderfunda is your
Training name
Funda is default name
Then run this command
Php bin/magento
setup:upgrade
In Admin panel (login
fast and clear your cache;)
Then check your theme
in content->config-> default theme and change the theme name
Two ways to override
a template in Magento 2
override product list magento 2 tutorial
https://www.youtube.com/watch?v=VF3I7RiBVEM
https://www.rakeshjesadiya.com/how-to-override-template-phtml-files-in-magento-2/
Module part -> like as
blog
Front->backend->db->show
all setup.
Create
New Module In Magento 2
Backend (Admin)
Menu
System Configuration
Grid
(Listing/Add/Edit/Delete)
ACL (Access Control List)
Create Tables and Insert
Sample News in Database
Frontend
Add News Links in Footer
News Listing
News Details
Use Events and Observers
Code Structure of module Magento 2
Block
Controller
etc
adminhtml
menu.xml
routes.xml
system.xml
frontend
routes.xml
ac.xml
config.xml,
di.xml,
module.xml
events.xml
Helper
i18n model
Setup
view
Plugin
composer.json
registration.php
Description of Module all steps
composer.json
You can
install module by composer and set another meta data.
registration.php
This file
register the module.
Block
This is
part of MVC. It’s Content view classes
Controller
It’s
content php controller. It’s part of mvc pattern
etc
All configuration file is here like as module.xml, menu.xml, system.xml, route.xml etc.
These file
describe here which is under etc folder.
etc/module.xml
In this
file under show module version or module name and any dependency.
etc/acl.xml
ACL file define the access control list for a given module.
it defines available set of permission to access the resources.
etc/config.xml
It’s system configuration
etc/di.xml
We write the dependency in this file.
etc/event.xml
When
we create observe class or we use observe class then use the event.xml file.
etc/adminhtml/menu.xml
This XML file adds new menu items to the
Magento admin panel.
etc/adminhtml/route.xml
What will be the front name of the
module. The contents of this XML file tells Magento to route requests that use
the front Name of this module.
etc/adminhtml/system.xml
This is a configuration file which is
used to create configuration fields in 2 system configuration
I18n
It’s
containing localization file.
Model
It’s
containing php model classes as part of MVC.
Setup
You can
crate table by this setup
View
Design
Template , email template and layout files.
Plugin
You can
change orginal class behavior by plugin.
It's contains plugin class. A class that modifies the
behavior of original, public methods for any class or interface
Helper
The helper class c ontains the methods. Methods can be
called from any template file, block, model, controller class or even from
another helper.
Basic
Required files for Module
registration.php
etc/module.xml
composer.json
Where is live Custom Modules?
or
Live Custom Modules or
where live Modules file show
If you install module by composer then module goes to under root
"vendor/VendorName/ModuleName"
If you install module by manual then module goes to under
"app/code/VendorName/ModuleName"
We create news blog or news model
Start Here step by step
1.
Create Admin Menu Item and Page View
We
understand this image that we crate this menu in admin panel. These steps are
given blow in down…|
When you
want to create menu in admin panel then some directory structure here you flow
only and after complete the steps then your menu will be created
1. This is directory structure
App/code/StreamMkt/News in this
folder all file & folder will be create.
Vendor Name : StreamMkt
Module Name : News
1st steps:
1.
app/code/StreamMket/News
composer.json
registration.php
etc/module.xml
app/code/StreamMket/News
composer.json
{
"name": "streammkt/news",
"description": "A module that creates for
news",
"type": "magento2-module",
"version": "1.0.0",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"require": {
"php": "~5.6.0|7.0.2|7.0.4|~7.0.6|~7.4.27"
},
"autoload": {
"files": [ "registration.php" ],
"psr-4": {
"Rsgitech\\News\\": ""
}
}
}
This is very important, you
can change according your vender or module name
Vender Name : streammkt || you
can change name like “Training”
Module Name : news || you
can change name like “test”
"name": "streammkt/news",
2nd Step
app/code/StreamMket/News
registration.php
Vender Name : StreamMkt ||
Remember ! here vendor name according to “case sensitive word”
Module Name : News ||
'StreamMkt_News'
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'StreamMkt_News',
__DIR__
);
?>
3rd
Step
app/code/StreamMket/News/etc
module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="StreamMkt_News" setup_version="1.0.0">
</module>
</config>
4th Step
app/code/StreamMket/News/etc/adminhtml/
1. menu.xml
2. routes.xml
1.menu.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
<menu>
<add id="StreamMkt_News::streammkt" title="StreamMkt" translate="title" module="StreamMkt_News" sortOrder="90" dependsOnModule="StreamMkt_News" resource="StreamMkt_News::streammkt"/>
<add id="StreamMkt_News::news" title="News" translate="title" module="StreamMkt_News" parent="StreamMkt_News::streammkt" sortOrder="50" dependsOnModule="StreamMkt_News" resource="StreamMkt_News::news"/>
<add id="StreamMkt_News::news_allnews" title="All News" translate="title" module="StreamMkt_News" parent="StreamMkt_News::news" sortOrder="10" dependsOnModule="StreamMkt_News" action="news/allnews" resource="StreamMkt_News::news_allnews"/>
</menu>
</config>
Note: 1st id="StreamMkt_News::streammkt" here you can change streammkt change
Last : action="news/allnews
: this is route url your file open here or index file auto load.
2.route.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<!--Use router 'standard' for frontend route-->
<router id="admin">
<!--Define a custom route with id
and frontName-->
<route frontName="news" id="news">
<!--The module which
this route match to-->
<module name="StreamMkt_News"/>
</route>
</router>
</config>
5th Step
app/code/StreamMket/News/Controller/Adminhtml/AllNews
index.php
This
is action function. When Menu.xml file create and we give action name
action="news/allnews"
or action="news/allnews/index"
both are same
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<!--Use router 'standard' for frontend route-->
<router id="admin">
<!--Define a custom route with id
and frontName-->
<route frontName="news" id="news">
<!--The module which
this route match to-->
<module name="StreamMkt_News"/>
</route>
<!-- <route
id="customer">
<module
name="Mageplaza_HelloWorld" before="Magento_Customer" />
</route> -->
</router>
</config>
6th Step
app/code/StreamMket/News/view/adminhtml
foder : 1st : layout or 2nd templates
app/code/StreamMket/News/view/adminhtml/layout
news_allnews_index.xml
<?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">
<head>
<title>News</title>
</head>
<body>
<referenceContainer name="content">
<block class="Magento\Backend\Block\Template" template="StreamMkt_News::allnews.phtml"/>
</referenceContainer>
</body>
</page>
app/code/StreamMket/News/view/adminhtml/templates
allnews.phtml
<p> HELLO fR. tHIS IS MY 1ST MAGENTO NEWS BLOG</p>
Completed the menu module in admin