Magento 2 - Getting started.

36
About Me: Aneesh Sreedharan My company: 2Hats Logic Solutions www.2hatslogic.com [email protected]

Transcript of Magento 2 - Getting started.

Page 1: Magento 2 - Getting started.

About

Me: Aneesh SreedharanMy company: 2Hats Logic Solutions

[email protected]

Page 2: Magento 2 - Getting started.

Overview of Magento

• E-commerce software• Start by Varien• Evolving• Buying of eBay• Magento 2.0

Page 3: Magento 2 - Getting started.

Why Magento 2

• Why magento 1 to 2 change? - Magento 1 gets matured. - integration with technologies that are current standard in development. Like use of composer - modular and extensible than before. - Better admin interfaces

• Opportunities - There’s in excess of 240,000 shops on Magento

Page 4: Magento 2 - Getting started.

Magento 2 System requirements

• PHP version 5.5+• MySQL version 5.6.0+• PHP Extensions - PDO/MySQL, mbstring, mcrypt,

mhash, SimpleXML, curl, xsl, gd, ImageMagick 6.3.7 (or later) or both, soap, intl, bc-math,openssl

Page 5: Magento 2 - Getting started.

Getting started, Installation

• Download directly• Use composer (use packagist.org for packages)

• Authentication keys - username – public key, password – private key

Page 6: Magento 2 - Getting started.

Setup wizard, installation

Page 7: Magento 2 - Getting started.

Completing installation

• Empty pub/static folder in win server php <path to >bin/magento setup:static-content:deploy

Page 8: Magento 2 - Getting started.

Admin area

Page 9: Magento 2 - Getting started.

Magento CLI

• Command-Line Interface• php <Magento install dir>/bin/magento <command name>

• php <Magento install dir>/bin/magento list• php <Magento install dir>/bin/magento sampledata:deploy• php <Magento install dir>/bin/magento setup:upgrade

Page 10: Magento 2 - Getting started.

Main admin settings

• Stores > Configuration settings - General > Web - Base URL (secure and insecure) - General > Design – Theme selection - Sales > Checkout/shipping/Payment methods - Advanced > Developer – Debug- Enable template path hints

• System > Cache management• System > Index management• System > Web setup wizard

Page 11: Magento 2 - Getting started.

Folder structure comparison

Page 12: Magento 2 - Getting started.

Creating a theme• Create a directory for the theme

under app/design/frontend/<your_vendor_name>/<your_theme_name>.

• Add a declaration file theme.xml • optionally create etc directory and create a file

named view.xml.• Add a composer.json file.• Add registration.php.• Create directories for CSS, JavaScript, images, and fonts.• Configure your theme in the Admin panel.

Page 13: Magento 2 - Getting started.

Creating a theme directory• <your install dir>/app/design/frontend/<Vendor>/<theme_name>

Page 14: Magento 2 - Getting started.

Declare the theme• Copy vendor/magento/theme-frontend-blank/theme.xml to

app/design/frontend/<Vendor>/<theme_name>

• * optionally make it a composer package

Page 15: Magento 2 - Getting started.

Add registration.php• Create a file registration.php in

app/design/frontend/<Vendor>/<theme_name>

Page 16: Magento 2 - Getting started.

Configure product images• Create /etc/ folder in theme directory• Copy view.xml from existing theme like Magento-frontend-blank

Page 17: Magento 2 - Getting started.

Create directories for static files

Page 18: Magento 2 - Getting started.

Theme created - activation

Page 19: Magento 2 - Getting started.

How to find the templates

Page 20: Magento 2 - Getting started.

How to find the templates

Page 21: Magento 2 - Getting started.

Overriding templates• Vendor/magento/module-checkout/view/frontend/templates/cart/

minicart.phtml • Copy to

app/design/frontend/Hatslogic/mytheme/Magento_Checkout/templates/cart/minicart.phtml

Page 22: Magento 2 - Getting started.

Layout handling with xml files

• 1-column, 2column-left,-right, 3column• Magento uses xml files to handle page layout• vendor\magento\module-catalog\view\frontend\layout\ - <block> - <container> - before and after attributes - <referenceBlock> and <referenceContainer> - <move> - <argument>

Page 23: Magento 2 - Getting started.

Layout handling with xml files

Page 24: Magento 2 - Getting started.

Extending a layout• Extend Magento product view layout<Magento_Catalog_module_dir>/view/frontend/layout/catalog_product_view.xml<theme_dir>/Magento_Catalog/layout/catalog_product_view.xml

Page 25: Magento 2 - Getting started.

Overriding a module layout

Page 26: Magento 2 - Getting started.

Overriding a theme layout

Page 27: Magento 2 - Getting started.

Creating a custom module• Create module in folder <magento

install>/app/code/<Vendor>/<ModuleName>

• Main folders of Module- Block- Controller- etc (contains module.xml)- Model- Setup- view

Page 28: Magento 2 - Getting started.

Creating a custom module• Create module.xml in <install_dir>/app/code/<Vendor>/<Module>/etc/

• Create registration.php in <install_dir>/app/code/<Vendor>/<Module>

Page 29: Magento 2 - Getting started.

Creating custom module• Add composer.json file

Page 30: Magento 2 - Getting started.

Creating custom modules

# Enable a module php -f bin/magento module:enable Vendor_ModuleName

Php –f bin/magento module:enable Hatslogic_HelloWorld

# Update the setup/databasephp -f bin/magento setup:upgrade

Creates and entry in app/etc/config.php

Page 31: Magento 2 - Getting started.

Enable custom module - Issues

# there are no commands defined in the module namespace - an issue in composer.json - an issue in module.xml - wrong config of registration.php

Page 32: Magento 2 - Getting started.

Custom module – Routes

• Create a routes.xml file

• domain.com/hello_world/awesome/life

Page 33: Magento 2 - Getting started.

Custom module - Controllers

• Create a controller file

• domain.com/hello_world/awesome/life

Page 34: Magento 2 - Getting started.

Some interesting features

• Color swatches made easy• Javascript - jQuery• Performance - Varnish cache support• Improved checkout process• Backup/Rollback system• Admin UI

Page 35: Magento 2 - Getting started.

Resources

• http://devdocs.magento.com/• http://alanstorm.com/category/magento• http://inchoo.net/• http://laracasts.com

Page 36: Magento 2 - Getting started.

Thank you!

Keep in touch.

Skype : hatslogicEmail : [email protected]