Magento 2 API: Add Products to Cart & Checkout Place Order

In this article, we will look into how we can add products to the cart and complete the checkout process by placing an order using Magento API. The APIs used to create a cart, add products to the cart, place an order, etc. require customer token authentication. Create Shopping Cart We create an empty cart … Read more

Magento 2 API: Get Products

In this article, we will be looking into how we can get the Products in Magento 2 using its API. Get Product by SKU Get Multiple Products using SearchCriteria Get Single Product by product ID using SearchCriteria Anonymouse APIs Restriction The REST endpoints to get the stores’ information falls under the anonymous APIs category. However, … Read more

Magento 2: Search Repository using SearchCriteriaBuilder, Filter & FilterGroup

This article shows how we can search Magento Repositories using SearchCriteriaBuilder that implements SearchCriteriaInterface. An example is provided of how we can perform search on Product repository in Magento. Similarly, we can search for other entities like Category, Customer, Order, Invoice, CMS Page, CMS Block, etc. We can add different conditions to build custom search … Read more

Magento 2: Create/Add Product from module’s InstallData or UpgradeData Script

This article shows how you can add a product from your custom module’s InstallData or UpgradeData Setup script file. This code is useful when you need to auto add product while installing or upgrading your custom module. Add product from InstallData Setup Script This will add product when you install your custom module for the … Read more

Magento 2: Create/Add Configurable Product Programmatically

This article shows how you can add Configurable Product programmatically in Magento 2. I am using a standalone script for this purpose using Object Manager. You can use this code in your custom module as well by using Dependency Injection (DI) instead of Object Manager. Initialize Object Manager and Set the Area code The following … Read more

Magento 2: Create/Add Product Programmatically [Simple & Virtual Product with Image, Category & Custom Option]

This article shows how you can add Simple & Virtual products programmatically in Magento 2. This article also shows how you can: – add images to the product – assign the product to different categories – add custom options to the product I am using a standalone script for this purpose using Object Manager. You … Read more

Magento 2: Add / Delete / View Custom Options of Product Programmatically

Custom options on Magento products are designed to make simple products function like a configurable product with different choosing options like color, size, etc. before purchasing the product. In this tutorial, I present the code to create/add, view and delete custom options of a simple product in Magento 2. I am using a standalone script … Read more

Magento 2: Delete Duplicate Product Attributes Options Programmatically

This article shows how you can delete duplicate product attribute options in Magento 2. I am using a standalone script for this purpose. You can use this code in your custom module as well. Initialize Object Manager and Set the Area Code The following things are done in the below code: – Initialize the object … Read more