I am making custom Magento API to create products. I can make products using custom API. Now my requirements is to upload multiple images to that API.
Can anyone helps me for reference code to upload multiple product images programmatically ??
Following example works for me for creating simple procuts.
$simpleProduct->setTypeId('simple')
->setAttributeSetId($attributeSetId)
->setWebsiteIds([1])
->setName($params['product_name'].' '.$size_label)
->setSku('SKU_'.time().$size_label)
->setUrlKey(str_replace(" ","_",$params['product_name'])."_".time())
->setPrice($params['price'])
->setSize($size_value) // Set the 'color' attribute option value
->setVisibility(1)
->setStatus(1)
->setCategoryIds($CategoryIds)
->setStockData(['use_config_manage_stock' => 1, 'qty' => $size_qty, 'is_qty_decimal' => 0, 'is_in_stock' => $in_stock])
->setData('brand',$params['brand'])
->setData('color',$params['color'])
->setData('material',$params['material'])
->setData('type',$params['type'])
->setData('condition',$params['condition']);
$simpleProduct = $productRepository->save($simpleProduct);
$associatedProductIds[] = $simpleProduct->getId();
$simple_product_id = $simpleProduct->getId();
If anyone please guide me for this requirements.