Core

Using Capistrano for Magento 2 to Deploy

There are many different deployment strategies used to deploy code onto a Magento 2 store. One of the deployment tools used is Capistrano, specifically the Capistrano for Magento 2 package. This post will look into using Capistrano for Magento 2 to deploy onto a staging and production environment whilst using Git to version control the …

Bootstrap and Use Magento 2 in an External File

There may be occasions where you need to modify core Magento functionality using an external script. You might do this to import and export data from Magento or to add, modify or remove data quickly. To bootstrap and use Magento 2 in an external file requires a few lines of code to be added at …

Redirect Magento URLs to HTTPS and www using htaccess

Google promotes websites that have an SSL certificate installed by placing them higher in the search results. This requires configuration changes within Magento.
Configuration within the Magento admin
Assuming you have a valid SSL, you can enable secure links in the frontend and admin by changing the Use Secure URLs on Storefront and Use …

Common Parent Classes to Extend in Magento 2

Below shows a list of common parent classes to extend in Magento 2 when creating your own functionality that extends the Magento core application.
Blocks
If you need to add a frontend block class, the class should extend Magento\Framework\View\Element\Template.
<?php
namespace [Vendor]\[Module]\Block;

class YourBlock extends \Magento\Framework\View\Element\Template
{
}
Adminhtml blocks can extend from Magento\Backend\Block\Template, …

Applying Magento 2 Github Patches

There are times when Magento will add fixes to their code base via Github without adding them straight away to newly released versions of the framework. This is where applying Magento 2 Github patches can be useful to patch any bugs in the code without having to potentially wait weeks for Magento to release a …

Upgrading Magento 2

Upgrading Magento 1 systems was a tedious task involving installing a vanilla instance, copying over custom theme and application code and upgrading the database. Upgrading Magento 2 is now a lot simpler with the application code managed by composer.
In the Admin
In the admin area, Magento offers the ability to upgrade the system, located …

Deploying Static Content in Magento 2

Deploying static content in Magento 2 is performed via the command line. When running your Magento store in production mode, eventually you will need to run this command.
As we know in production mode, static files are not generated or cached, therefore they must be written to the Magento file system manually.
The below command …

Magento 2 Modes

There are three main types of Magento 2 mode that your store can run under: default, developer and production. The default mode is the mode set when you first download the Magento application. Magento does not recommend using this mode when either carrying out development work, or when running the application in a live environment.

Logging in Magento 2

Logging in Magento 2 has changed since the days of Magento 1.
In earlier versions of Magento, to log data to a file, you had to use the static log() or logException() method of the Mage.php class, which would either write data to the system.log, exception.log, or custom log files defined as an argument within …

Directory Structure Within Magento 2

The directory structure within Magento 2 has changed compared to earlier versions of Magento.
Learning the locations of the files and folders in Magento 2 might take some time, however there are similarities with the Magento 1 structure.
If you have downloaded Magento from the Magento website, the root directory will look like the following.