Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
empty_bundle_product.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
11 $productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
13 $product = $objectManager->create(\Magento\Catalog\Model\Product::class);
14 $product->setTypeId('bundle')
15  ->setAttributeSetId(4)
16  ->setWebsiteIds([1])
17  ->setName('Bundle Product')
18  ->setSku('bundle-product')
19  ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
20  ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
21  ->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1])
22  ->setPriceView(0)
23  ->setPriceType(0)
24  ->setShipmentType(1)
25  ->setWeightType(0)
26  ->setDescription('description')
27  ->setPrice(99);
28 
$productRepository