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: Get order option of configurable and bundle product in cart

We are not allowed to order configurable and bundle products directly. We have to select product options from product detail page of configurable or bundle product. Only then we can add the product to cart. The following code fetches the order option selected for configurable and bundle products: // For configurable product Mage::getModel('catalog/product_type_configurable')->getOrderOptions($this->getProduct()); // For … Read more

Magento: Get parent id of simple product associated to configurable product

Scenario: A simple product is associated with a configurable product. You have the id of the simple product. Now, you need the id of the configurable product with which the simple product is associated. Get parent product id, i.e. get id of configurable product from a simple product. Note: This method is deprecated after 1.4.2.0 … Read more