39,59 €
Over 50 practical recipes that will help you realize the full potential of Magento in order to build a professional online store
The book is for existing Magento users who want to gain further expertise and insights into managing, designing, and extending their online store in Magento to fit their business needs. Working knowledge of Magento and basic familiarity with programming is expected.
Magento 2 is an open source e-commerce platform that has all the functionality to function from small to large online stores. It is preferred by developers and merchants due to its new architecture, which makes it possible to extend the functionalities with plugins, a lot of which are now created by the community.
This merchant and developer guide is packed with recipes that cover all aspects of Magento 2. The recipes start with simple how-to's then delve into more advanced topics as the book progresses.
We start with the basics of setting up a Magento 2 project on Apache or Nginx. Next, you will learn about basics including system tools and caching to get your Magento 2 system ready for the real work. We move on to simple tasks such as managing your store and catalog configuration. When you are familiar with this, we cover more complex features such as module and extension development. Then we will jump to the final part: advanced Magento 2 extensions.
By the end of this book, you'll be competent with all the development phases of Magento 2 and its most common elements.
Step by step guide for real world tasks for Magento users to gain a more advanced insight on managing, extending and designing their e-commerce store to fit their business needs.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 296
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 authors, 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: March 2016
Production reference: 1210316
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78588-706-2
www.packtpub.com
Authors
Ray Bogman
Vladimir Kerkhoff
Reviewer
Kevin Schroeder
Commissioning Editor
Wilson D'souza
Acquisition Editor
Reshma Raman
Content Development Editor
Parshva Sheth
Technical Editors
Pranil Pathare
Manthan Raja
Copy Editor
Tasneem Fatehi
Project Coordinator
Nikhil Nair
Proofreader
Safis Editing
Indexer
Monica Ajmera Mehta
Graphics
Disha Haria
Production Coordinator
Arvindkumar Gupta
Cover Work
Arvindkumar Gupta
Ray and Vladimir have been THE BEST thing to happen to Magento ever since X.Commerce.
Ok, that may be a slight exaggeration..., but it remains true that besides the software itself, Magento has always thrived on the dedication and enthusiasm of its large community. Ray and Vladimir are prime examples of the literally hundreds of developers, merchants, project managers, extension providers, event organizers, and platform evangelists that contribute every day to help community members make the most of their Magento shop.
I met Ray and Vladimir in the early days of Magento and got to know them as two highly engaged Magento fanatics. They built shops, extended the functionality, and pushed Magento to its limits. Failed and succeeded more often than anyone can count. More importantly, they were always generous enough to share their learning with the community through blog posts, webinars, events, and as Magento Doctors!
After a not-to-be-specified number of days, the announcement—we finally have Magento 2! If there are two people in our community capable of taking a deep dive into this new amazing platform and giving us practical recipes, it will be Ray and Vladimir.
I look forward to seeing what we can make happen in this new chapter for Magento. A lot of things will change and this book will help you get started with over 50 recipes.
One thing, however, will never change: don't touch the core...
Guido Jansen
Magento Community Manager
Ray Bogman is an IT professional and Magento evangelist from the Netherlands. He started working with computers in 1983 as a hobby at first. In the past, he has worked for KPN, a large Dutch Telecom company, as a senior security officer.
He has been the CTO of Wild Hibiscus, Netherlands, since 2010, and cofounder and business creator of Yireo until 2011, Jira ICT since 2005, and CTO of SupportDesk B.V., which he cofounded in 2011.
At SupportDesk B.V., he is a Magento, Joomla, OroCRM, web / server / mobile performance specialist, and security evangelist. His focus during the day is business/product development and training webmasters and consultants about the power of Magento, from the basics up to an advanced level. He has trained over 1,000 Magento and 750 Joomla experts worldwide since 2005.
At Magento events such as Magento Developers Paradise, Meet Magento, and MagentoLive, he has been a regular speaker since 2009.
He has participated in reviewing Mastering Magento (2012), Mastering Magento Theme Design (2014), Magento Administration Guide (2014), Learning Magento Theme Development (2014), and the video, Mastering Magento (2013), all by Packt Publishing.
The writing of this book was a big thing for me. I spent every free minute with passion in writing this. I had many doubts to overcome this big challenge as a dyslexic person. But I never thought that writing this would give me lots of self-esteem, peace, and joy. This would not have happened without the loving support and patience of my wife, Mette, and daughter, Belize. Joining forces with my co-writer, Vladimir, was a lot of fun. Sharing thoughts and insights about our Magento passion was great.
Last but not least, I would like to thank all the people who made writing this possible.
Vladimir Kerkhoff is an experienced IT professional, 4-times Magento Certified Developer from the Netherlands, and working with Magento since late 2009.
Currently, Vladimir is the founder/owner of Genmato BV, a Magento extension development company. He is also available for cool freelance projects. Vladimir has had a long career in the IT industry. He started his career in 1992 in an IT company, managing customer corporate networks (Bionet, Novell Netware, and Windows Server). In 1996, he was the cofounder and CTO of Perfect InterNetworking Solutions (PINS), a large Dutch-managed hosting provider. After leaving PINS in 2009, he cofounded eFulFillers offering web shop fulfilment services based on the Magento platform.
The writing of this book was a nice new experience, forcing myself to dive into the new Magento 2 code and learn the new methods that are available.
Kevin Schroeder has more years of experience in software development and consulting than he would like to admit. He was worked at several notable companies, including Zend as a consultant and evangelist and Magento as a consultant with the Expert Consulting Group. After getting his first taste in browser testing, he realized that the current tooling amounted to cruel and unusual punishment and founded the Magium open source project under his company, 10n Software, with the purpose of making automated browser testing almost enjoyable and actually useful beyond just browser testing.
When he's not working on software, he is sleeping. When he's not sleeping, he is recording music (Coronal Loop Safari and Loudness Wars) or writing books (The IBMi Programmer's Guide to PHP, You want to do WHAT with PHP?, and Advanced Guide to PHP on the IBMi, all published by MC Press).
I would like to thank my wife, Laurie, and my three young 'uns who, after having me in their family, will have no problems coping with the rigors of adult life. Supreme thanks to life's Author, about whom many books have been written and none have been sufficient.
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://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
Magento is one of the most successful open source e-commerce platforms out there today. It is powerful enough to build small or enterprise businesses.
The first stable version of Magento was released in 2008. Since the beginning, lots of merchants have chosen Magento to be their platform with great success.
The current global ecosystem of Magento includes 240+ merchants, 300+ partners, and 4500+ certified developers, and this number is growing on a daily basis.
Over the last few years, e-commerce has changed a lot, so Magento announced a new platform that will support this. This new era of commerce is called Magento 2.
Magento 2 offers enhanced performance and scalability. The new platform is built from scratch to enable lots of new features. It supports both B2C and B2B businesses, and will serve the best omnichannel shopping experiences to their shoppers.
This book will provide you with the necessary insights to get a better understanding on what is needed to build such a powerful commerce platform.
The book is divided into several recipes, which show you which steps to take to complete a specific action. In each recipe, we have a section that explains how everything works.
It will cover installing a Magento 2 website, configuring your categories and products, performance tuning, creating a theme, developing a module, and much more.
At the end of this book, you will gain the knowledge to start building a success website.
Chapter 1, Installing Magento 2 on Apache and NGINX, is a totally different ballgame compared to Magento 1. Where Magento 1 could be installed through FTP or SSH, Magento 2 is installable only via the command-line interface for an experienced webmaster.
Chapter 2, Magento 2 System Tools, explains how to install Magento 2 via the command shell. Magento released a new powerful tool to manage and install sample data, reindex your database, back up your site, or flush your caches, which are just a few of the options.
Chapter 3, Enabling Performance in Magento 2, explains how to configure different types of caching options. In Magento 2, the Full Page Cache (FPC) can be handled by Varnish to give your store a performance boost. There are also external services that you can use as a cache.
Chapter 4, Creating Catalogs and Categories, shows you one of the major elements of a Magento store before creating products. Creating the correct product type including attributes is an important step in setting up a Magento store.
Chapter 5, Managing Your Store, covers setting up the correct tax rules, configuring an inventory, and creating customer groups.
Chapter 6, Creating a Magento 2 Theme, discusses the Magento 2 blank theme and how to use the fallback to create seasonal variations. It also explains how the new theme is set up and where files are stored.
Chapter 7, Creating Magento 2 Extensions – the Basics, contains the basic functions required to use extensions in a Magento 2 installation. It contains a brief introduction to new methods introduced in the Magento 2 framework and examples on how to create basic functions.
Chapter 8, Creating Magento 2 Extensions – Advanced, explains how to use advanced features in extensions for Magento 2. It also includes how to add unit/functional tests as this is a new requirement for extensions listed on the new Magento Connect.
The following setup is recommended for maximum enjoyment:
This book is intended primarily for intermediate to professional merchants, webmasters, DevOps, solution integrators, and PHP developers who are interested in Magento 2.
It will cover the basic and advanced features of Magento 2 DevOps, performance, theming, development, and system configuration.
In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also).
To give clear instructions on how to complete a recipe, we use these sections as follows:
This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.
This section contains the steps required to follow the recipe.
This section usually consists of a detailed explanation of what happened in the previous section.
This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.
This section provides helpful links to other useful information for the recipe.
In this book, you will find a number of text styles 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: "Go to your favorite browser and search using your yourdomain.com."
A block of code is set as follows:
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
Any command-line input or output is written as follows:
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: "Check on the second like for the Server API; this should be FPM/FastCGI."
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:
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/Magento2Cookbook_ColorImages.pdf.
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.
In this chapter, we will cover the basic tasks related to installing Magento 2 on Apache and NGINX. You will learn the following recipes:
This chapter explains how to install Magento 2 on a hosting environment. When installing a new Magento 2 instance, we can use either a Linux, Apache, MySQL, PHP (LAMP) or Linux, NGINX, MySQL, PHP (LEMP) setup. Currently, options such as MariaDB or HHVM are equivalent to MySQL or PHP. Only HHVM will be converted in this chapter.
We will install a clean Magento 2 setup on a hosted virtual private server (VPS) for more advanced users and an easy-to-use installation on Hypernode.
The recipes in this chapter will primarily focus on a basic setup of how to install Magento 2. However, in some situations, we will dive in deeper related to the subject.
While Magento requirements differ from Magento 1, we will be using the latest and finest version from PHP, HHVM, NGINX, Apache, Redis, MySQL, and Ubuntu.
Creating a new Magento 2 stack could bring up minor issues. Always update to the latest available version, if possible.
Throughout the following recipes, we will install the latest Apache 2.4.x version on a Software as a Service (SaaS) platform hosted by DigitalOcean. The current Apache version supports HTTP/2. This recipe will show you how to do this.
HTTP/2 is an optimized version of the Hypertext Transfer Protocol (HTTP), also known as HTTP version 2 (HTTP/2). Some of the new features of HTTP/2 are a more efficient usage of network resources and network latency. HTTP/2 allows multiple concurrent connections over a single Transmission Control Protocol (TCP) connection at once, which optimizes TCP load. Merging CSS and JS is not necessary anymore. HTTP/2 service also provides the possibility to use server push, which allows a proactive push of resources to the client.
For this recipe, you will need to create an account at DigitalOcean https://www.digitalocean.com/. No other prerequisites are required.
For the purpose of this recipe, let's assume that we need to create an Apache hosting environment. The following steps will guide you through this:
The output of this command is as follows:
If you have followed steps 1 to 9, you will be able to see if the web server is running. Go to your favorite browser and search using your yourdomain.com.
In the DigitalOcean control panel, you can create multiple snapshots at all times during the recipes. This will help you in restoring an old version or just going back in time.
Let's recap and find out what we did throughout this recipe. In steps 1 through 3, we create a clean hosting server setup using DigitalOcean. Next, we connect the Droplet IP to your domain name in DNS. After login via SSH, we are able to update the server and continue to the process of installing Apache 2 via a third-party repository. Depending on the Ubuntu setup, we need to change the version name, such as precise, trusty, wily, vivid, or xenial, to install the software.
In step 8, we submit a key that will validate the repository before we can start installing the Apache 2 software. In step 9, we use a simple command to update the repository and start installing.
If you want to check whether Apache is running fine, use one of the following commands:
Throughout the following recipes, we will install the latest NGINX 1.9.x version on a SaaS platform hosted by DigitalOcean. The current NGINX version supports HTTP/2. This recipe will show you how to do it.
For this recipe, you will need to create an account at DigitalOcean https://www.digitalocean.com/. No other prerequisites are required.
For this cookbook, we will use a commercial SaaS hosting provider to get a production-ready environment. You can use any other solution out there to build on your preferred stack.
For the purpose of this recipe, let's assume that we need to create an NGINX hosting environment. The following steps will guide you through this:
The output of this command is as follows:
If you have followed steps 1 to 6, you will be able to see if the web server is running. Go to your favorite browser and search using your yourdomain.com.
In the DigitalOcean control panel, you can create multiple snapshots at all times during the recipes. This will help you in restoring an old version or just going back in time, such as switching from Apache to NGINX or back.
Let's recap and find out what we did throughout this recipe. In steps 1 through 5, we used the same Droplet to install NGINX. All steps are alike, but instead of installing Apache, we use NGINX instead. The only big difference is that it is an official NGINX repository.
The current market share of NGINX is around 15% worldwide compared to 50% of Apache on active sites. Over the last couple of years, NGINX has grown and is commonly used as a stable web server for Magento hosting:
http://news.netcraft.com/archives/2015/03/19/march-2015-web-server-survey.html
If you want to check whether NGINX is running fine, use one of the following commands:
