Magento 2: Get Payment Methods (All/Active/Used)

This article shows how to get payment methods in Magento 2. We will be fetching 3 types of payment methods. They are: 1) All Payment Methods 2) Active/Enabled Payment Methods 3) Payment Methods that have been used while placing orders I will be showing both ways (Dependency Injection & Object Manager way) to get payment … Read more

Magento: Get Payment Methods (All/Active/Used)

This article shows how to get payment methods in Magento 1. We will be fetching 3 types of payment methods. They are: 1) All Payment Methods 2) Active/Enabled Payment Methods 3) Payment Methods that have been used while placing orders To get all payment methods, we can either use Mage_Payment_Helper_Data or Mage_Payment_Model_Config class. To get … Read more

Magento: Get Customer Groups

This article shows how to get all customer groups name and id in Magento 1. To get all customer groups, we will be using Mage_Customer_Model_Resource_Group_Collection class. Here’s the code: $collection = Mage::getResourceModel('customer/group_collection'); $customerGroups = $collection->toOptionArray(); // adding a new element to the beginning of customerGroups array array_unshift($customerGroups, array('value'=>'', 'label'=>'Any')); Sample Output: print_r($customerGroups); Array ( [0] … Read more

Magento 2: Install via Composer and Command Line (CLI)

This article/tutorial show how to download and install Magento 2 through command line interface (CLI). We will be using Composer to download Magento 2 from Magento’s repository. Here is the step-by-step guide on installing Magento 2 via command line: 1) Check & Verify System Requirements Before, downloading and installing Magento 2, we need to make … Read more

Magento 2: Get Product’s Custom Option Value from Cart & Order

This article shows how to get custom option values of products/items added to cart or products of any order in Magento 2. I will simply be using ObjectManager for this example. Get custom options of products present in shopping cart $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $cart = $objectManager->get('\Magento\Checkout\Model\Cart'); // get cart items $items = $cart->getItems(); // get … Read more

Magento 2: Get all Categories of any/current Product

This article shows how we can get list of all categories from current product or any particular product as well. Both ways (Dependency Injection & Object Manager way) are shown below: Using Dependency Injection (DI) Below is a block class of my custom module (Chapagain_HelloWorld). I have injected object of \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory, \Magento\Catalog\Model\ProductRepository and \Magento\Framework\Registry classes … Read more

Magento 2: Upgrade/Update using Command Line & Composer

This article shows how you can upgrade/update your Magento 2 version through command line using composer. Upgrading to Magento 2.3.x is a bit different than that of Magento 2.2.x or 2.1.x. At first, I will show the commands that need to be run to upgrade Magento2 to version 2.1.x or 2.2.x. Upgrading Magento to 2.2.x … Read more