10 ->setTypeId(\
Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
11 ->setAttributeSetId(4)
13 ->setName(
'Simple Product 1')
16 ->setDescription(
'Description with <b>html tag</b>')
17 ->setVisibility(\
Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
18 ->setStatus(\
Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
20 ->setStockData([
'use_config_manage_stock' => 1,
'qty' => 100,
'is_qty_decimal' => 0,
'is_in_stock' => 1])
24 ->setTypeId(\
Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
25 ->setAttributeSetId(4)
27 ->setName(
'Simple Product 2')
30 ->setDescription(
'Description with <b>html tag</b>')
31 ->setVisibility(\
Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
32 ->setStatus(\
Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
34 ->setStockData([
'use_config_manage_stock' => 1,
'qty' => 100,
'is_qty_decimal' => 0,
'is_in_stock' => 1])
42 ->setTypeId(\
Magento\Catalog\Model\Product\Type::TYPE_BUNDLE)
43 ->setAttributeSetId(4)
45 ->setName(
'Bundle Product')
46 ->setSku(
'bundle-product')
47 ->setDescription(
'Description with <b>html tag</b>')
48 ->setShortDescription(
'Bundle')
49 ->setVisibility(\
Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
50 ->setStatus(\
Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
53 'use_config_manage_stock' => 0,
55 'use_config_enable_qty_increments' => 1,
56 'use_config_qty_increments' => 1,
60 ->setBundleOptionsData(
63 'title' =>
'Bundle Product Items',
64 'default_title' =>
'Bundle Product Items',
73 ->setBundleSelectionsData(
79 'selection_can_change_qty' => 1,
82 'selection_price_type' => 0,
83 'selection_price_value' => 0.0,
91 'selection_can_change_qty' => 1,
94 'selection_price_type' => 0,
95 'selection_price_value' => 0.0,
102 )->setCustomAttributes([
104 'attribute_code' =>
'price_type',
105 'value' => \
Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC
108 "attribute_code" =>
"price_view",
112 ->setCanSaveBundleSelections(
true)
113 ->setHasOptions(
false)
114 ->setAffectBundleProductSelections(
true);
115 if (
$product->getBundleOptionsData()) {
125 $bundleLinks =
$product->getBundleSelectionsData();
126 if (!empty($bundleLinks[$key])) {
127 foreach ($bundleLinks[$key] as
$linkData) {
133 $link->setSku($linkProduct->getSku());
135 if (isset(
$linkData[
'selection_can_change_qty'])) {
136 $link->setCanChangeQuantity(
$linkData[
'selection_can_change_qty']);
156 foreach (
$product->getExtensionAttributes()->getBundleProductOptions() as
$option) {
157 foreach (
$option->getProductLinks() as $selection) {
169 $product->setSkipCheckRequiredOption(
true);
182 ->setCustomerIsGuest(
true)
183 ->setStoreId(
$objectManager->get(\
Magento\Store\Model\StoreManagerInterface::class)->getStore()->getId())
184 ->setReservedOrderId(
'test01')
193 ->setCode(
'freeshipping_freeshipping')
196 $quote->getShippingAddress()->setShippingMethod(
'freeshipping_freeshipping');
197 $quote->getShippingAddress()->addShippingRate(
$rate);
198 $quote->getPayment()->setMethod(
'checkmo');
defined('TESTS_BP')||define('TESTS_BP' __DIR__
foreach($product->getExtensionAttributes() ->getBundleProductOptions() as $option) $buyRequest
static getObjectManager()