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: 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: Get Custom Option Value from Order

This article contains code snippet to get custom options value of all products in any Magento order. Suppose, there is a product with a custom option dropdown list. You chose one of the option from the dropdown list and purchased that product. The code below fetches product’s custom option value selected in any particular order. … Read more