Skip to content

simple-product

Auto Added by WPeMatico

How to programmatically assign simple product to configurable on Magento 2.4

How do you programmatically assign simple product to configurable? What I tried: $configurableProduct = $this->objectManager->create(‘MagentoConfigurableProductModelProductTypeConfigurable’); $configurableProduct->setUsedProductAttributes($product, array($product_jsa_type_attribute_id)); $product->setNewVariationsAttributeSetId(4); $product->setAssociatedProductIds(array( $productObj->getIdBySku($ticketProduct[‘product_id’]), $productObj->getIdBySku($couponProduct[‘product_id’]), ));

How to assign a simple product in Configurable Product in Magento 2

Hello I am using given below code to add simple product in configurable product.but it is not properly working. $productId = 1; // Configurable Product Id $objectManager = MagentoFrameworkAppObjectManager::getInstance(); $product = $objectManager->create(‘MagentoCatalogModelProduct’)->load($productId); // Load Configurable Product $attributeModel = $objectManager->create(‘MagentoConfigurableProductModelProductTypeConfigurableAttribute’); $position… Read More »How to assign a simple product in Configurable Product in Magento 2