Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Magento 2 Cookbook
Magento 2 Cookbook

Magento 2 Cookbook: Exploring Magento 2 in the form of recipes

Arrow left icon
Profile Icon Bogman Profile Icon Kerkhoff
Arrow right icon
Mex$561.99 Mex$803.99
Full star icon Full star icon Full star icon Full star icon Empty star icon 4 (1 Ratings)
eBook Mar 2016 342 pages 1st Edition
eBook
Mex$561.99 Mex$803.99
Paperback
Mex$1004.99
Subscription
Free Trial
Arrow left icon
Profile Icon Bogman Profile Icon Kerkhoff
Arrow right icon
Mex$561.99 Mex$803.99
Full star icon Full star icon Full star icon Full star icon Empty star icon 4 (1 Ratings)
eBook Mar 2016 342 pages 1st Edition
eBook
Mex$561.99 Mex$803.99
Paperback
Mex$1004.99
Subscription
Free Trial
eBook
Mex$561.99 Mex$803.99
Paperback
Mex$1004.99
Subscription
Free Trial

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

Magento 2 Cookbook

Chapter 2. Magento 2 System Tools

In this chapter, we will cover the basic tasks related to managing the system tools of Magento 2. You will learn the following recipes:

  • Installing Magento 2 sample data via GUI
  • Installing Magento 2 sample data via the command line
  • Managing Magento 2 indexes via the command line
  • Managing Magento 2 cache via the command line
  • Managing Magento 2 backup via the command line
  • Managing Magento 2 set mode (MAGE_MODE)
  • Transferring your Magento 1 database to Magento 2

Introduction

This chapter explains how to install and manage Magento 2 on a production-like environment. We will be installing a new Magento 2 instance via the shell command with and without sample data. Besides the setup, managing Magento 2 is different from the current Magento version. We will be using a lot of tools from the command line so basic shell knowledge is advised. The command-line tool in the /bin directory is similar to the current Swiss army knife tool in the current Magento version known as n98-magerun.

Using bin/magento and Composer is one of the new key features in Magento 2 that will rock your world.

The recipes in this chapter will focus primarily on a more advanced setup of how to install Magento 2 and manage it. However, in some situations, we will dive in deeper related to the subject.

Here is an overview of all the command-line tools in Magento 2:

root@mage2cookbook:/var/www/html# bin/magento
Magento CLI version 2.0.0

Usage:
 command [options] [arguments]

Options...

Installing Magento 2 sample data via GUI

Installing Magento 2 via the graphical user interface (GUI) is not new. We have already done this in Chapter 1, Installing Magento 2 on Apache and NGINX. Now, we will be installing a new clean version including the sample data.

The sample data can be installed during and at the end of the procedure. We will be using a composer.json file for our setup prerequisites. First, we will be installing a clean version with sample data, and later, I will show you how to install it at the end in case you already have a preinstalled version.

Getting ready

For this recipe, we will use a Droplet created in Chapter 1, Installing Magento 2 on Apache and NGINX, at DigitalOcean, https://www.digitalocean.com/. We will be using NGINX, PHP-FPM, and a Composer-based setup. No other prerequisites are required.

How to do it...

For the first step, you can either create a new Droplet or rebuild a clean Droplet based on a Ubuntu or RedHat DigitalOcean image.

The option to rebuild...

Installing Magento 2 sample data via the command line

Installing Magento 2 via the shell is not new. In the current Magento version, it was already possible using the install.php file. The configuration looked like this:

/usr/local/bin/php -f install.php -- \
--license_agreement_accepted "yes" \
--locale "en_US" \
--timezone "America/Los_Angeles" \
--default_currency "USD" \
--db_host "mysql.example.com" \
--db_name "your_db_name" \
--db_user "your_db_username" \
--db_pass "your_db_password" \
--db_prefix "" \
--admin_frontname "admin" \
--url "http://www.examplesite.com/store" \
--use_rewrites "yes" \
--use_secure "no" \
--secure_base_url "" \
--use_secure_admin "no" \
--admin_firstname "your_first_name" \
--admin_lastname "your_last_name" \
--admin_email "your_email@example.com" \
--admin_username "your_admin_username...

Managing Magento 2 indexes via the command line

In the current version of Magento, using indexes is one of the most important key features. Without the correct indexes, we will not be able to use Magento properly.

What do the indexes do, and why are they so important? One of the key elements is to make things run faster. Without indexing, Magento 2 would have to calculate data on the fly. In Magento 2, we will be using the following nine indexes:

  • Customer Grid: This indexer rebuilds the customer's grid. This is a new indexer in Magento 2 for optimized rendering of the adminhtml backend pages.
  • Category Products: This indexer creates the association between categories and products based on the associations that you set in the backend on the categories and relates to the Product Categories indexer. The flat catalog indexer creates a flat optimized table in the database.
  • Product Categories: This indexer creates the association between products and categories based on the associations that...

Managing Magento 2 cache via the command line

Cache management is one of the new optimized key features in Magento 2. We will be using the following cache types:

Cache types

Cache type code name

Description

Configuration

config

Magento collects configuration from all modules, merges it, and saves the merged result to the cache. This cache also contains store-specific settings stored in the filesystem and database.

Clean or flush this cache type after modifying configuration files.

Layout

layout

This is the compiled page layout (that is, the layout components from all components).

Clean or flush this cache type after modifying layout files.

Block HTML output

block_html

This is the HTML page fragments per block.

Clean or flush this cache type after modifying the view layer.

Collections data

collections

This is the result of database queries.

If necessary, Magento cleans up this cache automatically, but third-party developers can put any data in any segment of the cache.

Clean...

Managing Magento 2 backup via the command line

Every production environment needs a proper backup plan. By default, Magento 2 has a complete set of options to create and roll back backups.

When creating a backup, we can use one of the following options:

Option

Meaning

Backup file name

--code

This creates a backup from the filesystem (excluding /var and /pub/static

var/backups/<timestamp>_filesystem.tgz

--media

This creates a backup from the /media directory

var/backups/<timestamp>_filesystem_media.tgz

-db

This creates a backup from the current database

var/backups/<timestamp>_db.gz

Tip

Besides the Magento backup options, it is always advisable to use an alternative backup solution connected to a backup storage.

Getting ready

When creating a backup, Magento will store it in the var/backups directory. In this recipe, we will refer to the bin/magento setup:backup and bin/magento setup:rollback options.

How to do it...

For the purpose of this recipe, let's assume...

Introduction


This chapter explains how to install and manage Magento 2 on a production-like environment. We will be installing a new Magento 2 instance via the shell command with and without sample data. Besides the setup, managing Magento 2 is different from the current Magento version. We will be using a lot of tools from the command line so basic shell knowledge is advised. The command-line tool in the /bin directory is similar to the current Swiss army knife tool in the current Magento version known as n98-magerun.

Using bin/magento and Composer is one of the new key features in Magento 2 that will rock your world.

The recipes in this chapter will focus primarily on a more advanced setup of how to install Magento 2 and manage it. However, in some situations, we will dive in deeper related to the subject.

Here is an overview of all the command-line tools in Magento 2:

root@mage2cookbook:/var/www/html# bin/magento
Magento CLI version 2.0.0

Usage:
 command [options] [arguments]

Options...

Installing Magento 2 sample data via GUI


Installing Magento 2 via the graphical user interface (GUI) is not new. We have already done this in Chapter 1, Installing Magento 2 on Apache and NGINX. Now, we will be installing a new clean version including the sample data.

The sample data can be installed during and at the end of the procedure. We will be using a composer.json file for our setup prerequisites. First, we will be installing a clean version with sample data, and later, I will show you how to install it at the end in case you already have a preinstalled version.

Getting ready

For this recipe, we will use a Droplet created in Chapter 1, Installing Magento 2 on Apache and NGINX, at DigitalOcean, https://www.digitalocean.com/. We will be using NGINX, PHP-FPM, and a Composer-based setup. No other prerequisites are required.

How to do it...

For the first step, you can either create a new Droplet or rebuild a clean Droplet based on a Ubuntu or RedHat DigitalOcean image.

The option to rebuild...

Left arrow icon Right arrow icon

Key benefits

  • Take advantage of the latest features in Magento 2 to set up an e-commerce store that fits your business needs
  • Packed with several advanced recipes, not just to manage your online store, but to extend and design it as well
  • Written in a cookbook style, you can pick and choose your recipe to carry out your day- to- day Magento store tasks

Description

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.

Who is this book for?

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.

What you will learn

  • Set up a Magento 2 project on Apache or Nginx.
  • Transfer your Magento 1 database to Magento 2 using the Magento 2 system tools.
  • Boost the performance of Magento 2 by enabling different types of caching.
  • Build a Magento 2 multi-store by creating a root catalog, subdirectories, and products.
  • Create and manage pages, blocks, and front-end apps.
  • Manage your Magento store by setting up the correct TAX rules.
  • Design custom themes within the Magento 2 framework.
  • Create basic and advanced extensions using Magento 2.

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Mar 28, 2016
Length: 342 pages
Edition : 1st
Language : English
ISBN-13 : 9781785883408
Vendor :
Magento
Languages :
Concepts :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want

Product Details

Publication date : Mar 28, 2016
Length: 342 pages
Edition : 1st
Language : English
ISBN-13 : 9781785883408
Vendor :
Magento
Languages :
Concepts :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Mex$85 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Mex$85 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total Mex$ 2,995.97
Magento 2 Cookbook
Mex$1004.99
Magento 2 Development Cookbook
Mex$1128.99
Magento 2 Developer's Guide
Mex$861.99
Total Mex$ 2,995.97 Stars icon

Table of Contents

9 Chapters
1. Installing Magento 2 on Apache and NGINX Chevron down icon Chevron up icon
2. Magento 2 System Tools Chevron down icon Chevron up icon
3. Enabling Performance in Magento 2 Chevron down icon Chevron up icon
4. Creating Catalogs and Categories Chevron down icon Chevron up icon
5. Managing Your Store Chevron down icon Chevron up icon
6. Creating a Magento 2 Theme Chevron down icon Chevron up icon
7. Creating Magento 2 Extensions – the Basics Chevron down icon Chevron up icon
8. Creating Magento 2 Extensions – Advanced Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
(1 Ratings)
5 star 0%
4 star 100%
3 star 0%
2 star 0%
1 star 0%
Noph Veluvan Jul 07, 2016
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Good to have if you want to develop your own code. I am still new to it.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.