Home » Archive

Articles in the Magento 2 Category

Magento, Magento 2 »

[12 May 2016 | 4 Comments]

This article shows how we can check if the current page URL is homepage URL in Magento 2.
Below is a block class of my custom module (Chapagain_HelloWorld). I have injected object of Logo block class in the constructor of my module’s block class.
app/code/Chapagain/HelloWorld/Block/HelloWorld.php

Magento, Magento 2 »

[9 May 2016 | One Comment]

This article shows how we can check if current URL and frontend URl are secure (https) or not in Magento 2.
Below is a block class of my custom module (Chapagain_HelloWorld). I have injected object of StoreManagerInterface in the constructor of my module’s block class.

Magento, Magento 2 »

[5 May 2016 | 9 Comments]

This article shows how we can get store information in Magento 2. We will be fetching store id, store code, store name, store url, and store’s website id. We also write a function which checks if the store is active or not.
Below is a block class of my custom module (Chapagain_HelloWorld). I have injected object of StoreManagerInterface in the constructor of my module’s block class.

Magento, Magento 2 »

[28 Apr 2016 | One Comment]

This article shows how we can get our store’s currency code, currency symbol, and currency rate in Magento 2. We will be fetching all base, default and current currency code. We will also be fetching available currency codes and allowed currency codes.
Using Dependency Injection (DI)

Magento, Magento 2 »

[14 Apr 2016 | One Comment]

Magento 2 uses Symfony’s Console Component for its command-line interface or tool (CLI) where we can execute different commands for different tasks related to installation and configuration.
Through the Command Line Interface (CLI) tool in Magento 2, you can perform different tasks like:

Magento, Magento 2 »

[7 Apr 2016 | Comments Off on Magento 2: Simple Hello World Module – Step-by-Step Beginner Tutorial]

This beginner step-by-step tutorial shows how you can create a simple and basic HelloWorld module / extension in Magento 2. The necessary files are listed with the code.
This module just calls a block function in template file to print Hello World text.

Magento, Magento 2 »

[28 Mar 2016 | One Comment]

This article shows how we can check if a module is installed / enabled or active in Magento 2.
Both Dependency Injection and Object Manager ways are shown below.
Using Dependency Injection (DI)

Magento, Magento 2 »

[24 Mar 2016 | 2 Comments]

In Magento 1.x, you could call/print any module’s template block in any other template (phtml) file with the following code:

Magento, Magento 2 »

[21 Mar 2016 | One Comment]

In Magento 1.x, you could call/print the CMS Static Block in template file with the following code:

Magento, Magento 2 »

[4 Mar 2016 | 4 Comments]

This article shows how we can get parent category, children categories and total number of products in a category in Magento 2.
Below is a block class of my custom module (Chapagain_HelloWorld). I have injected object of \Magento\Catalog\Model\CategoryFactory class in the constructor of my module’s block class.

Magento, Magento 2 »

[1 Mar 2016 | 5 Comments]

This article shows how we can get all products of a particular category in Magento 2.
Both Dependency Injection and Object Manager way of coding is shown below.
Using Dependency Injection (DI)

Magento, Magento 2 »

[28 Feb 2016 | 3 Comments]

This article shows how we can get product collection in Magento 2.
Using Dependency Injection (DI)
Below is a block class of my custom module (Chapagain_HelloWorld). I have injected object of \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory class in the constructor of my module’s block class.

Magento, Magento 2 »

[26 Feb 2016 | 2 Comments]

This article shows how we can get related product, upsell product and crosssell products in Magento 2.
Below is a block class of my custom module (Chapagain_HelloWorld). I have injected object of \Magento\Framework\Registry class in the constructor of my module’s block class.

Magento, Magento 2 »

[19 Feb 2016 | One Comment]

This article shows how to create and destroy different types (Checkout, Customer, Catalog) of sessions in Magento 2.
As you can see below, there are different types of session classes present in Magento 2.

Magento, Magento 2 »

[17 Feb 2016 | Comments Off on Magento 2: Get Current URL & Base URL]

This article shows how we can get current and base URL in Magento 2.
Both Dependency Injection and Object Manager ways of coding are given below.
Using Dependency Injection (DI)