Magento 2 Theme Design - Fernando J Miguel - E-Book

Magento 2 Theme Design E-Book

Fernando J Miguel

0,0
33,77 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Create stunning and responsive Magento 2 themes for your business

Key Features



  • Realize the full potential of theme design in Magento 2
  • Design attractive themes for your e-commerce store to make them stand out amongst the crowd
  • Practical skills and examples ensure you can take what you've learnt to your own projects – limited only by your own creativity!

Book Description



Magento is the e-commerce software and platform trusted by the world's leading brands. Using Magento's powerful theming engine, you can control the look, content, and functionality, and easily launch a flexible e-commerce website. However, because of its powerful features, developing Magento themes is easier said than done.

This book aims to leverage the enhancements to theme designing in Magento 2 to the fullest. It will show you how to gear up the performance of your e-commerce website.

We begin by introducing Magento 2 and its features along with implementing a local development Magento environment. We then move on to discuss the concepts of the Magento theme structure such as templates, inheritance, customization, and override.

Further on, we explore the Magento UI Library, which is a new feature available in Magento 2.0. We will create a new Magento 2.0 theme named MyCake Store using Magento Bootstrap from Maven E-commerce and also create print strategies for the Magento 2.0 theme. We will also create and customize a new theme proposal for the Magento admin panel. At the end, we will integrate Magento 2.0 to Twitter and integrate it with social bookmarking and finally deploy our new Magento 2.0 theme.

What you will learn



  • Implement a local development Magento environment
  • Understand the workings of the Magento theme structure
  • Edit an existing Magento theme to satisfy your business needs
  • Create print strategies for the Magento 2.0 theme
  • Generate specific blocks to improve the Magento 2.0 theme
  • Explore specific Magento programming Methods to improve the Magento 2.0 theme
  • Customize the Magento 2.0 admin panel to create a new Magento 2.0 admin theme
  • Build a Twitter module for Magento 2.0 and integrate Magento 2.0 with social bookmarking

Who this book is for



This book is for web designers and developers with existing knowledge of CSS, HTML, and XML who wish to create themes for Magento 2. Existing Magento 1.x theme designers who now want to develop themes for Magento 2 will also find this book useful.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB

Seitenzahl: 199

Veröffentlichungsjahr: 2016

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Magento 2 Theme Design - Second Edition
Credits
About the Author
About the Reviewer
www.PacktPub.com
Why subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Introduction to Magento 2
What is Magento?
Magento 2's features
Differences between Magento 1 and Magento 2
Showcase of Magento themes
Venroy
Alcatel Onetouch
Cultcha Kids
Challenges of Magento 2 theme design
Why create a custom Magento 2 theme?
Installing Magento 2
XAMPP PHP development environment
XAMPP installation
XAMPP for Windows installation
XAMPP for Linux installation
XAMPP for OS X installation
Downloading Magento 2
Summary
2. Exploring Magento Themes
Magento terminology
Magento vendors and themes
Magento websites and Magento stores
What makes a Magento theme?
Unique aspects of a Magento theme
Default Magento 2 themes
Magento Luma theme
Magento Blank theme
Blocks and pages in Magento
Magento theme inheritance
Custom Variables
Good practices in Magento theming
Summary
3. Magento 2 Theme Layout
Magento 2 and Model-View-Controller architecture
Magento 2 Command-Line Interface
Magento 2 theme files
Magento 2 cache system
Magento 2 layout system
Creating your first Magento 2 theme
Magento Modes
Disabling Magento's cache
Theme development
Creating the static files directories
Creating a theme logo
Applying the theme
Magento 2 theme debug
Summary
4. Magento UI Library
Magento 2 UI
LESS and CSS preprocessing
Custom variables
Functions
Mixins
Operators
Nestings
LESS compilation in Magento 2
The Magento UI library
Testing the Magento UI library
Summary
5. Creating a Responsive Magento 2 Theme
The BookStore theme project
Managing dependencies with Composer
Installing Composer on Unix-like operating systems
Installing Composer on Windows
Building the BookStore theme
Applying new CSS to the BookStore theme
Creating the BookStore logo
Changing your store's design
Adding content with Magento CMS
Displaying featured categories on the home page
Developing Magento 2 templates
Summary
6. Magento 2 Styles Debugging
Increasing productivity by creating flow test styles
Debugging styles in Magento
Client-side debugging mode
Server-side debugging mode
Using the Grunt task runner to debug
Installing Node.js on Linux
Installing Node.js on Windows
Installing Node.js on OSX
Installing Grunt
Testing Grunt
grunt watch
Applying changes to Bookstore with Grunt
Summary
7. Magento UI Components
The Magento UI components
UI listing/grid component
UI listing/grid secondary components
Filter
Pagination
TreeMass action
Column
UI-select
Multiselect
Inline edit
Bookmark
Resize
Sticky header
Export button
File uploader
Form component
UI components control definition file
Magento sample module form
Summary
8. Magento Layout Development
The Magento page layout
Layout instructions and types
Extend and override a layout
Layout customizations
Set the page layout
Managing static resources
Working with static blocks
Working with dynamic blocks
Customizing templates
Customizing templates with a new language
Summary
9. Magento 2 JavaScript
Magento 2 JavaScript structure
Initializing and locating JavaScript component
Initializing JavaScript
Mapping the JavaScript resources
Magento jQuery widgets
Creating a Tabs widget
Creating a jCarousel component for Promo module
Summary
10. Social Media in Magento 2
Magento components
Development workflow
Understanding the composer.json
Developing the Sweet Tweet module
The Twitter REST API
The Twitter OAuth library
The Module directory structure
Coding the composer.json file
Declaring the XML configuration files and registration.php
Programming the controllers
Programming the blocks
Programming the Observer
Programming the View layer
Enabling the module
Summary
11. Theme Development Best Practices
Why I should worry about it?
Best practices in Magento 2 development
Always use the Magento architecture
The Magento technology stack
PHP standard recommendations
PSR-1 – basic coding standards
PSR-2 – coding style guide
PSR-4 – autoloader
Strategies for customizing your themes
Seeking external resources to improve
Community Magento
The Magento 2 official repository
The Magento blog
Magento Stack Exchange
Blogs about Magento development
Inchoo
Mukesh Chapagain
Alan Storm
Summary
12. Magento Theme Distribution
The packaging process
Packaging your theme
Magento component validation
Hosting your theme
Hosting your project on GitHub and Packagist
Hosting your project in a private repository
Magento Marketplace
Submitting your theme
Summary

Magento 2 Theme Design - Second Edition

Magento 2 Theme Design - Second Edition

Copyright © 2016 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: July 2009

Second edition: October 2016

Production reference: 1241016

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham 

B3 2PB, UK.

ISBN 978-1-78588-822-9

www.packtpub.com

Credits

Authors

Fernando J Miguel

Richard Carter

Project Coordinator

Ritika Manoj 

Commissioning Editor

Wilson D'souza

Proofreader

Safis Editing

Acquisition Editor

Smeet Thakkar 

Indexer

Tejal Daruwale Soni 

Content Development Editor

Parshva Sheth

Graphics

Kirk D'Penha

Technical Editor

 Rutuja Vaze

Production Coordinator

Shraddha Falebhai

Copy Editor

Safis Editing

About the Author

Fernando J Miguel has been working with software development since 2003 and has continued researching methods to improve his skills through hard work and commitment. He has worked with CMS since 2004 and Magento, specifically, since 2009.

A Certified Professional Scrum Master by the Scrum Alliance, he loves to apply agile as a way of life and improves himself to achieve excellence in work and customers and team satisfaction. He has a background on different technologies and is always seeking the best solution for the current project.

As a University professor, he motivates students to find their own paths and seek excellence in their professional IT careers.

Fernando has a bachelor's degree in Information Systems (Módulo University – Caraguatatuba/SP –  Brazil). He has post graduated in Project Management/PMI-PMBOK (Cruzeiro do Sul University – São Paulo/SP – Brazil).

He worked as a Technical Reviewer for Magento 1.4 Theming cookbook, Mastering Magento, Mastering Magento [Video], Mastering Magento Theme Design.

He was the Author of Magento 2 Development Essentials (2016).

I dedicate all my work to my brother Wagner for all the support. Without family support, I never could be here. Thank you to all my family.

About the Reviewer

Richard Carter is a seasoned front-end web developer who has worked with Magento since 2008. He lives in Newcastle upon Tyne in the North East of England.

He is the founder of the e-commerce agency Peacock Carter, an e-commerce and web design agency based in the North East of England, and has worked for clients including the Scottish Government, City & Guilds, NHS, and the University of Edinburgh.

Richard is the author of four books on Magento, including Magento Responsive Theme Design, and has written three further books on e-commerce and content management systems.

Thanks to Gillian, who is forever at my side.

www.PacktPub.com

For support files and downloads related to your book, please visit www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

https://www.packtpub.com/mapt

Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.

Why subscribe?

Fully searchable across every book published by PacktCopy and paste, print, and bookmark contentOn demand and accessible via a web browser

To my grandmother Mildes and my mother Edneia, wherever they are, I'm sure they are very happy with my work. To my beloved wife Elizabete for the countless hours of patience with my work. Love you.

Preface

Digital buyers are increasing the economy around the world, and Information Technology (IT) is providing the necessary subsidies to allow the customers to buy services and products over the Internet. According to the research conducted by Statista (http://goo.gl/BSCiuO), in 2016, 1.12 billion people worldwide are expected to buy goods and services online.

Since the launch of Amazon.com, the first commercial-free 24-hour e-commerce website, the universe of software development’s techniques have evolved and new approaches are emerging, such as cloud computing: previously, an embryonic idea, today a concrete application.

The Magento Commerce company, recognized as the leading e-commerce platform in the 2015 Internet Retailer Top 1000, B2B 300, and Hot 100 lists, is in constant evolution since the first Magento Community Edition (CE) system version in 2008. Launched recently, Magento CE 2.0 has great features and takes advantage of the newest client-server techniques, providing a mature e-commerce system and a promising professional area to explore.

Magento CE 2.0 works with a modern theming and layout framework, extensive and efficient APIs, stable interfaces with the business logic layer and, mainly, a reliable system to allow the implementation of custom functionalities.

Magento 2 Theme Development covers the newest concepts in Magento theme development. The mission of this book is to give to the readers the necessary information to start mastering the Magento Theme Development concepts.

Enjoy the read.

What this book covers

Chapter 1, Introduction to Magento 2, introduces you to the basic concepts of Magento 2, shows the Magento websites that are on the market, and guides you through building a local development environment Magento 2.

Chapter 2, Exploring Magento Themes, teaches you the structure of the themes in Magento 2, as well as the importance of the Luma and Blank themes.

Chapter 3, Magento 2 Theme Layout, shows you how to work with the Model-View-Controller architecture, the command-line interface, the layout system, and theme debuging.

Chapter 4, Magento UI Library, teaches you how to use the Magento UI library, LESS compilation, and CSS preprocessing.

Chapter 5, Creating a Responsive Magento 2 Theme, guides you to the development of a new theme for Magento 2.

Chapter 6, Magento 2 Styles Debugging, teaches you how to create a flow to test your styles, client-side debugging, server-side debugging, and the Grunt task runner.

Chapter 7, Magento UI Components, teaches you how to work with UI components: listing, grid, a form.

Chapter 8, Magento Layout Development, shows you the layout instructions, and the types, and techniques required to customize your template.

Chapter 9, Magento 2 JavaScript, teaches you how to work with JavaScript in Magento and jQuery widgets by developing a simple extension.

Chapter 10, Social Media in Magento 2, guides you through the development of a new extension that integrates Magento 2 with social media.

Chapter 11, Theme Development Best Practices, shows you the best practices of developing themes for Magento 2.

Chapter 12, Magento Theme Distribution, shows you an overview of the packaging process to sell and share your developed theme.

What you need for this book

The following software is recommended for maximum enjoyment:

Linux, OSX, or Windows (7, 8, or 10)XAMPPBrowser (Google Chrome or Firefox)Code editor (Sublime Text, Notepad++, or Atom.io)

Who this book is for

This book is for web developers, Magento developers, and students who want to work with Magento 2. This book builds a solid path to follow that will help you master the concepts of theme development in Magento 2.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Log in as $var and enter the password you chose earlier with config."

A block of code is set as follows:

<?php \Magento\Framework\Component\ComponentRegistrar::register(     \Magento\Framework\Component\ComponentRegistrar::MODULE,     'Packt_SweetTweet',     __DIR__ );

Any command-line input or output is written as follows:

packt@magento ~ $ grunt clean

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Clicking the Next button moves you to the next screen."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

Log in or register to our website using your e-mail address and password.Hover the mouse pointer on the SUPPORTtab at the top.Click on Code Downloads & Errata.Enter the name of the book in the Searchbox.Select the book for which you're looking to download the code files.Choose from the drop-down menu where you purchased this book from.Click on Code Download.

You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

WinRAR / 7-Zip for WindowsZipeg / iZip / UnRarX for Mac7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Magento-2-Theme-Design. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.

Chapter 1. Introduction to Magento 2

"Computers themselves, and software yet to be developed, will revolutionize the way we learn" - Steve Jobs.

The Internet is an important sector of many businesses, both large and small, in the modern world. It's now rare for a company to not have at least a basic web presence, and increasingly unlikely that a company's products are not sold online. Magento is a powerful e-commerce system, used by international organizations such as Nike, Nestlé, Gant, and Fun4Kids.

This is what we will see in this chapter:

Take a look at what Magento 2 is and what it can doDiscover the differences between Magento 1.x and Magento 2.xSee the default themes that come installed with Magento 2.xLook at a showcase of custom Magento themes from real websitesFind out the particular challenges in customizing Magento themesInstall and configure Magento 2 ready for theming

As you will come to see, Magento is quite a large e-commerce system and this book will guide you through customizing its quirks and eccentricities.

What is Magento?

Magento (http://www.magentocommerce.com) is a highly customizable e-commerce platform and content management system. Magento is one of the most widely used e-commerce systems to create online stores around the world by providing management of inventory, orders, customers, payments, and much more. Magento has a powerful scalable architecture that follows the best software development patterns on the market. Take a look at the following screenshot:

Magento is written in the PHP programming language using an object-orientated architecture, allowing features such as additional payment gateways, integration with social networks such as Twitter and Facebook, and customization for different product types to be easily added.

The default installation of Magento provides a huge number of e-commerce and related features, supports multiple stores being managed from the same control panel, and importantly for us—provides the ability for very heavily customized themes.

At the beginning, Magento was very criticized for being slow when loading its pages, which could be at least partially mitigated with the use of built-in caches. However, in Magento 2 we have a considerable evolution on system performance with the adoption of the LESS preprocessor, Full Page Caching, Indexers Optimization, and the adoption of new techniques and technologies, as you will see in the following chapters.

Magento 2's features

As with other e-commerce systems, Magento allows products to be added, edited, manipulated, and organized within categories. You are able to control your product's names, descriptions, prices, and upload multiple photographs for each product in your store. Magento also lets you create variations of products in your store, so you can have one product that is available in multiple colors (such as blue, red, and black) within Magento. In other e-commerce systems, you may have to add the blue, red, and black products as three separate products.

In addition to these standard e-commerce features, Magento also has the ability to perform the following:

Manage both the sending of e-mail newsletters and the managing of subscribers to these listsManage non-product pages through its content management system (CMS)Organize polls of your store's visitors

Additional features are available in Magento Enterprise Edition, but this book concentrates on Magento 2 Community Edition; everything in this book can be applied to all editions of Magento 2.

Differences between Magento 1 and Magento 2

There are some fairly major differences between Magento 1 and Magento 2. Magento 2 provides major updates on its previous version after some hard work to create the best solutions to old issues such as performance and security. The updates can be illustrated by the following list:

Caching: There's a built-in Full Page Cache (FPC) on the Community Edition and Varnish support for improved performance.Extensions and Themes: Magento 2 is more organized and extensible now. The extensions and themes have your own files of code and layout.File structure: More organized directories and structures inside the Model View-Controller (MVC) proposal.Performance: Improved performance and scalability.Security: Enhancements in security with the adoption of good software development practices (design patterns) and SHA-256 password hashing included.User Experience (UX): Besides the frontend changes, the Magento 2 admin area is now more user-friendly with substantial positive changes such as the new admin area structure and management.

Magento 2, compared with Magento 1.9, shows some changes, but more than that, there is an improvement in the system's behavior and processes. The code is more organized; it separates the Magento framework's native extensions, providing a powerful environment for modularization and solution development:

The main changes in the structure of Magento 2 are as follows:

The skin directory does not exist anymore. All the files of a module or theme are stored in its specific scope.The native modules and themes of Magento 2 installation are in the vendor directory.The pub directory contains all the CSS and PHTML files precompiled.The composer.json file manages the project dependencies.

Tip

For further information about the Magento 2 directory structure, please access http://devdocs.magento.com/guides/v2.0/extension-dev-guide/module-file-structure.html .

In Magento 1, the theme system works by rendering the layout files (PHTML) from the app/design/frontend/MyTheme directory and by rendering the CSS, JS, and Image files from the skin/frontend/MyTheme directory. However, in Magento 2, all the layout and CSS files are in the same directory, Theme.

The themes of Magento 2 are located in the app/design/frontend/<Vendor>/ directory. This location differs with built-in themes, such as the Luma theme, which is located in vendor/magento/theme-frontend-luma.

The different themes are stored in separate directories:

Each Vendor can have one or more themes attached to it, so you can develop different themes inside the same Vendor.

The theme structure of Magento 2 is illustrated as follows:

How Magento 2's theme structure works is quite simple to understand: each <Vendor>_<Module> corresponds a specific module or functionality of your theme. For example, Magento_Customer has specific CSS and HTML files to handle the customer module of the Magento vendor. Magento handles a significant number of modules. So, I strongly suggest you navigate to the vendor/magento/theme-frontend-luma folder to see the available modules for the default theme.

In the structure of Magento 2, we have three main files that manage the themes' behavior:

composer.json: Describes the dependencies and meta informationregistration.php: Registers your theme in the systemtheme.xml: Declares the theme in the system and is used by the Magento system to recognize the theme

All the theme files, inside the structure explained in the previous section, can be divided into Static View Files and Dynamic View Files. The Static View Files are not processed by the server (images, fonts, js) and the Dynamic View Files are processed by the server before delivering the content to the user (template and layout files).

Static files generally are published in the following folders:

/pub/static/frontend/<Vendor>/<theme>/<language><theme_dir>/media/<theme_dir>/web

Tip

For further information, please access the official Magento Theme structure documentation: http://goo.gl/ov3IUJ

In Chapter 2 , Exploring Magento Themes, you will see this structure in action by exploring the default themes of Magento 2. Now, let's take a look at a showcase of running Magento 2 solutions.