Home » Archive

Articles in the Magento Category

Magento »

[29 Mar 2016 | No Comment]

This article shows how you can filter child products associated with a configurable product by the child product’s attribute value.
Suppose, we have a configurable product with two attributes (‘size‘ and ‘color‘) and we want to select only those child products with certain size and/or certain color. Let’s say, we want to select only those products that have color as ‘Red‘.

Magento, Magento 2 »

[28 Mar 2016 | No Comment]

This article shows how we can check if a module is installed / enabled or active in Magento 2.
Below is a block class of my custom module (Chapagain_HelloWorld). I have injected object of \Magento\Framework\Module\Manager class in the constructor of my module’s block class.
app/code/Chapagain/HelloWorld/Block/HelloWorld.php

Magento, Magento 2 »

[24 Mar 2016 | No Comment]

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 | No Comment]

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

Magento »

[17 Mar 2016 | No Comment]

To display/show product price including tax amount, you need to do some configuration settings.
1. Create Tax Rule
You need to create tax rules (Sales -> Tax -> Manage Tax Rules). For this, you can refer to different tutorials available over the internet on creating Tax rules.

Magento »

[10 Mar 2016 | No Comment]

This article shows how to use AJAX on Magento with Prototype Javascript Library.
Scenario
I had one scenario where I had to check whether a customer is already registered or not via AJAX.

Magento, Magento 2 »

[4 Mar 2016 | 3 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.
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.
app/code/Chapagain/HelloWorld/Block/HelloWorld.php

Magento, Magento 2 »

[28 Feb 2016 | No Comment]

This article shows how we can get product collection in Magento 2.
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.
app/code/Chapagain/HelloWorld/Block/HelloWorld.php

Magento, Magento 2 »

[26 Feb 2016 | One Comment]

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 »

[24 Feb 2016 | No Comment]

Here is a quick tip on how to change/update logo image from Magento backend/admin. You don’t need to login to FTP and upload/replace files. You also don’t need to change the code of any file.
Here is the step-by-step guide to change the logo from backend:

Magento, Magento 2 »

[19 Feb 2016 | No 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 | No Comment]

This article shows how we can get current and base URL in Magento 2.
Below is a block class of my custom module (Chapagain_HelloWorld). I have injected object of StoreManagerInterface & UrlInterface in the constructor of my module’s block class. Both of them can be used to fetch base and current URL. In below class, in function getStoreManagerData(), object of StoreManagerInterface is used to print the base and current url and in function getUrlInterfaceData() function, object of UrlInterface is used to print the base and current url.
app/code/Chapagain/HelloWorld/Block/HelloWorld.php

Magento, Magento 2 »

[12 Feb 2016 | 3 Comments]

This article shows how we can get current category and current product data 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.
app/code/Chapagain/HelloWorld/Block/HelloWorld.php

Magento, Magento 2 »

[4 Feb 2016 | One Comment]

In Magento 1, you could simply write your own custom log with the following code:

and it would be saved at MAGENTO_ROOT/var/log/your_log_file.log