33,77 €
Create stunning and responsive Magento 2 themes for your business
Key Features
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
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:
Seitenzahl: 199
Veröffentlichungsjahr: 2016
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
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
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.
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.
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.
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.
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.
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.
The following software is recommended for maximum enjoyment:
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.
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 cleanNew 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."
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
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.
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.
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:
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:
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!
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 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.
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.
"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:
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.
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.
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:
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.
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:
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:
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:
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:
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.
