Create an Admin theme

1.Create Admin theme directory
In the app/design/adminhtml directory create a new <Vendor>/<admin_theme> directory.

2.Add a declaration theme.xml
Add or copy from an existing theme.xml to your theme directory app/design/adminhtml/Vendor/<admin_theme>

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
	<title>Ataur Admin</title> <!-- your theme's name -->
	<parent>Magento/backend</parent> <!-- the parent theme. Example: Magento/backend -->
</theme>	

3.Add registration.php
In your theme directory app/design/adminhtml/<Vendor>/<admin_theme> create a registration.php file.

<?php
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
\Magento\Framework\Component\ComponentRegistrar::register(
	\Magento\Framework\Component\ComponentRegistrar::THEME,
	'adminhtml/Ataur/my-first-admin-theme', // Example: 'adminhtml/Magento/backend'
	__DIR__
); 

4.Admin theme logo
In the default Magento/backend theme lib/web/images/magento-logo.svg is used as theme logo. To override it, in your theme directory, create a web/images sub-directory, and add your custom file named magento-logo.svg

5.Apply an Admin theme
Prerequisites:
1.Set your Magento application to the developer mode.
2.Create a custom theme for the Admin panel.
3.Add a new custom module or decide to use existing custom module. The module must load after the Magento_Theme module. To ensure this, add the following code app/code/[VendorName]/[ModuleName]/etc/module.xml

(replace placeholders with your module information):

<module name="Ataur_Override" setup_version="2.0.1"> <!-- Example: "Magento_Backend -->"
	<sequence>
		<module name="Magento_Theme"/>
	</sequence>
</module>

6.Specify the custom Admin theme in di.xml
You need to specify the admin theme to be used in the <your_module_dir>/etc/di.xml file. Add it, if the file does not yet exist in your module.

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
	<!-- Admin theme. Start -->
	<type name="Magento\Theme\Model\View\Design">
		<arguments>
			 <argument name="themes" xsi:type="array">
				 <item name="adminhtml" xsi:type="string">Ataur/my-first-admin-theme</item> <!-- Example: "Magento/backend" -->
			 </argument>
		 </arguments> 
	</type>
	<!-- Admin theme. End -->
</config>

7.Update components to actually apply the Admin theme
For your changes to take effect, you need to update Magento components. For this,
run the php bin/magento setup:upgrade command in your command line. If prompted, also run
php bin/magento setup:di:compile

error face: Controller preference not working after setup:di:compile
solution: Have you tried to run php bin/magento setup:static-content:deploy afterwards?
And just in case, run again php bin/magento setup:upgrade at the very end of operations.

Advertisements

Magento2 Installation

Magento2 download by composer

1.You have to setup composer in your htdocs
2.Must be check magento prerequisites
3.Go to magento documentation and find on the left side Getting Started > Install Magento using Composer
3.Select which version is compatibility with your php
4.Avoiding so many problem just change from D:\xampp\php\php.ini

memory_limit=328M
max_input_time=300
max_execution_time=18000

extension=php_intl.dll
extension=php_soap.dll
extension=php_xsl.dll

5.Enter the following command. Obviously copy this code from Magento Open Source metapackage. Fact of (version)

php composer.phar create-project –repository-url=https://repo.magento.com/ magento/project-community-edition <installation directory name>

Version specify:
php composer.phar create-project –repository-url=https://repo.magento.com/ magento/project-community-edition=2.1.7 /installation/directory name

or

composer create-project –repository-url=https://repo.magento.com/ magento/project-community-edition <installation directory name>

6.When prompted, enter your authentication keys from your magento profile.
Your public key is your username.
your private key is your password.

7.Now you can see it’s downloading so many files. After few minutes Successfully you can see
Generating autoload files

Magento2 install by command line

D:\xampp\htdocs\magento2> composer
D:\xampp\htdocs\magento2> composer install
D:\xampp\htdocs\magento2> php bin/magento setup:install

php bin/magento setup:install –base-url=http://127.0.0.1/magento2/ –db-host=localhost –db-name=test-magento2 –db-user=root –db-password= –admin-firstname=Ataur –admin-lastname=Rahman –admin-email=appointbd@gmail.com –admin-user=webTech –admin-password=webTech1234@ –language=en_US –currency=USD –timezone=America/Chicago –use-rewrites=1

Magento 2 CLI

php bin/magento help
php bin/magento list
php bin/magento indexer:reindex
php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento cache:disable
php bin/magento cache:enable
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy

[doest not generate files in the pub/static folder. Try to run below command]
php bin/magento setup:static-content:deploy -f

Set the Magento mode

Developer mode:
You should use the Developer mode while you are developing customizations or extensions

php bin/magento deploy:mode:show
php bin/magento deploy:mode:set developer

Production mode:
You should run Magento in Production mode once it is deployed to a production server. Production mode provides the highest performance in Magento 2.

Install sample data after Magento

Do not install sample data if your Magento application is set for production mode. Switch to developer mode first. Installing sample data in production mode fails.

php bin/magento sampledata:deploy

If you’re installing sample data after installing Magento, you must also run the following command to update the database and schema:

php bin/magento setup:upgrade

Create a storefront theme

Go to /app/design/frontend

1.Declare your theme


<?xml version="1.0" encoding="UTF-8"?>
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
     <title>My First Theme</title> <!-- your theme's name -->
     <parent>Magento/blank</parent> <!-- the parent theme, in case your theme inherits from an existing theme -->
     <media>
         <preview_image>media/preview.jpg</preview_image> <!-- the path to your theme's preview image -->
     </media>
 </theme>

2.Add registration.php

<?php
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::THEME,
    'frontend/stark/my-first-theme',
    __DIR__
);

3.Configure images
Product image sizes and other properties used on the storefront are configured in a view.xml configuration file. For example, here is the view.xml of the Magento Blank theme: app/design/frontend/Magento/blank/etc/view.xml  copy that and past your view.xml file

4.Include CSS
include your CSS in default_head_blocks.xml of the Magento_Theme module, which defines the default <head> page section for all Magento pages.

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <css src="css/styles-m.css" />
        <css src="css/styles-l.css" media="screen and (min-width: 768px)"/>
        <css src="css/print.css" media="print" />
        <css src="css/custom.css" media="print"/>
    </head>
</page>

Magento theme location

Storefront themes are conventionally located under app/design/frontend/<Vendor>/. Though technically they can reside in other directories. For example Magento built-in themes can be located under vendor/magento/theme-frontend-<theme_code> when a Magento instance is deployed from the Composer repository.

Resize catalog images

Generally, product images are cached while saving the product. However, the magento catalog:images:resize command enables you to resize all images for display on your storefront.

php bin/magento catalog:images:resize