Magento 2: Get Product Stock Quantity and Other Stock Information

This article shows how to get stock quantity (qty) of a product in Magento 2. We can also fetch other stock information like minimum quantity (min_qty), minimum sale quantity (min_sale_qty), maximum sale quantity (max_sale_qty), see if a product is in stock (is_in_stock), etc. We will be using Magento 2’s Service Layer for this task. Use … Read more

Magento 2: Load Product by ID and SKU

This article shows how to load product by id and sku in Magento 2. We will be using Magento 2’s Service Layer for this task. Use of Service Layer is highly encouraged by Magento. Below is a block class of my custom module (Chapagain_HelloWorld). I have injected object of \Magento\Catalog\Model\ProductRepository class in the constructor of … Read more

Git: Very Basic Commands

Here are some very basic git commands. They are very useful for git beginners. Here is the step-by-step guide: Go to any folder where you want to create local copy of your repository cd /path/to/your/directory Create a working copy of a local repository git clone /path/to/repository For remove server: git clone username@host:/path/to/repository For example, if … Read more