Skip to content

Commit 9441edb

Browse files
author
Maksym Aposov
committed
MAGETWO-38347: Second product from bundle product is ordered as separate item after checkout
1 parent 9f9355f commit 9441edb

File tree

1 file changed

+98
-142
lines changed

1 file changed

+98
-142
lines changed

dev/tests/integration/testsuite/Magento/Sales/_files/quote_with_bundle.php

Lines changed: 98 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -7,134 +7,102 @@
77
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
88
/** Create simple and bundle products for quote*/
99
$simpleProducts[] = $objectManager->create('Magento\Catalog\Model\Product')
10-
->setTypeId(
11-
\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE
12-
)->setId(
13-
1
14-
)->setAttributeSetId(
15-
4
16-
)->setWebsiteIds(
17-
[1]
18-
)->setName(
19-
'Simple Product 1'
20-
)->setSku(
21-
'simple-1'
22-
)->setPrice(
23-
10
24-
)->setDescription(
25-
'Description with <b>html tag</b>'
26-
)->setVisibility(
27-
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
28-
)->setStatus(
29-
\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
30-
)->setCategoryIds(
31-
[2]
32-
)->setStockData(
33-
['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1]
34-
)->save();
10+
->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
11+
->setId(1)
12+
->setAttributeSetId(4)
13+
->setWebsiteIds([1])
14+
->setName('Simple Product 1')
15+
->setSku('simple-1')
16+
->setPrice(10)
17+
->setDescription('Description with <b>html tag</b>')
18+
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
19+
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
20+
->setCategoryIds([2])
21+
->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1])
22+
->save();
3523

3624
$simpleProducts[] = $objectManager->create('Magento\Catalog\Model\Product')
37-
->setTypeId(
38-
\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE
39-
)->setId(
40-
2
41-
)->setAttributeSetId(
42-
4
43-
)->setWebsiteIds(
44-
[1]
45-
)->setName(
46-
'Simple Product 2'
47-
)->setSku(
48-
'simple-2'
49-
)->setPrice(
50-
10
51-
)->setDescription(
52-
'Description with <b>html tag</b>'
53-
)->setVisibility(
54-
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
55-
)->setStatus(
56-
\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
57-
)->setCategoryIds(
58-
[2]
59-
)->setStockData(
60-
['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1]
61-
)->save();
25+
->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
26+
->setId(2)
27+
->setAttributeSetId(4)
28+
->setWebsiteIds([1])
29+
->setName('Simple Product 2')
30+
->setSku('simple-2')
31+
->setPrice(10)
32+
->setDescription('Description with <b>html tag</b>')
33+
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
34+
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
35+
->setCategoryIds([2])
36+
->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1])
37+
->save();
6238

6339
$product = $objectManager->create('Magento\Catalog\Model\Product');
64-
$product->setTypeId(
65-
\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE
66-
)->setId(
67-
3
68-
)->setAttributeSetId(
69-
4
70-
)->setWebsiteIds(
71-
[1]
72-
)->setName(
73-
'Bundle Product'
74-
)->setSku(
75-
'bundle-product'
76-
)->setDescription(
77-
'Description with <b>html tag</b>'
78-
)->setShortDescription(
79-
'Bundle'
80-
)->setVisibility(
81-
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
82-
)->setStatus(
83-
\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
84-
)->setStockData(
85-
[
86-
'use_config_manage_stock' => 0,
87-
'manage_stock' => 0,
88-
'use_config_enable_qty_increments' => 1,
89-
'use_config_qty_increments' => 1,
90-
'is_in_stock' => 0,
91-
]
92-
)->setBundleOptionsData(
93-
[
40+
$product
41+
->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE)
42+
->setId(3)
43+
->setAttributeSetId(4)
44+
->setWebsiteIds([1])
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)
51+
->setStockData(
9452
[
95-
'title' => 'Bundle Product Items',
96-
'default_title' => 'Bundle Product Items',
97-
'type' => 'select',
98-
'required' => 1,
99-
'delete' => '',
100-
'position' => 0,
101-
'option_id' => '',
102-
],
103-
]
104-
)->setBundleSelectionsData(
105-
[
53+
'use_config_manage_stock' => 0,
54+
'manage_stock' => 0,
55+
'use_config_enable_qty_increments' => 1,
56+
'use_config_qty_increments' => 1,
57+
'is_in_stock' => 0,
58+
]
59+
)
60+
->setBundleOptionsData(
10661
[
10762
[
108-
'product_id' => $simpleProducts[0]->getId(),
109-
'selection_qty' => 1,
110-
'selection_can_change_qty' => 1,
63+
'title' => 'Bundle Product Items',
64+
'default_title' => 'Bundle Product Items',
65+
'type' => 'select',
66+
'required' => 1,
11167
'delete' => '',
11268
'position' => 0,
113-
'selection_price_type' => 0,
114-
'selection_price_value' => 0.0,
11569
'option_id' => '',
116-
'selection_id' => '',
117-
'is_default' => 1,
11870
],
71+
]
72+
)
73+
->setBundleSelectionsData(
74+
[
11975
[
120-
'product_id' => $simpleProducts[1]->getId(),
121-
'selection_qty' => 1,
122-
'selection_can_change_qty' => 1,
123-
'delete' => '',
124-
'position' => 0,
125-
'selection_price_type' => 0,
126-
'selection_price_value' => 0.0,
127-
'option_id' => '',
128-
'selection_id' => '',
129-
'is_default' => 1,
130-
]
131-
],
132-
]
133-
)->setCanSaveBundleSelections(
134-
true
135-
)->setAffectBundleProductSelections(
136-
true
137-
)->save();
76+
[
77+
'product_id' => $simpleProducts[0]->getId(),
78+
'selection_qty' => 1,
79+
'selection_can_change_qty' => 1,
80+
'delete' => '',
81+
'position' => 0,
82+
'selection_price_type' => 0,
83+
'selection_price_value' => 0.0,
84+
'option_id' => '',
85+
'selection_id' => '',
86+
'is_default' => 1,
87+
],
88+
[
89+
'product_id' => $simpleProducts[1]->getId(),
90+
'selection_qty' => 1,
91+
'selection_can_change_qty' => 1,
92+
'delete' => '',
93+
'position' => 0,
94+
'selection_price_type' => 0,
95+
'selection_price_value' => 0.0,
96+
'option_id' => '',
97+
'selection_id' => '',
98+
'is_default' => 1,
99+
]
100+
],
101+
]
102+
)
103+
->setCanSaveBundleSelections(true)
104+
->setAffectBundleProductSelections(true)
105+
->save();
138106

139107
//Load options
140108
$typeInstance = $product->getTypeInstance();
@@ -158,12 +126,8 @@
158126
);
159127
$product->setSkipCheckRequiredOption(true);
160128

161-
162129
$addressData = include __DIR__ . '/address_data.php';
163-
$billingAddress = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
164-
'Magento\Quote\Model\Quote\Address',
165-
['data' => $addressData]
166-
);
130+
$billingAddress = $objectManager->create('Magento\Quote\Model\Quote\Address', ['data' => $addressData]);
167131
$billingAddress->setAddressType('billing');
168132

169133
/** @var Magento\Quote\Model\Quote\Address $shippingAddress */
@@ -172,31 +136,23 @@
172136

173137
/** @var \Magento\Quote\Model\Quote $quote */
174138
$quote = $objectManager->create('Magento\Quote\Model\Quote');
175-
$quote->setCustomerIsGuest(
176-
true
177-
)->setStoreId(
178-
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
179-
'Magento\Store\Model\StoreManagerInterface'
180-
)->getStore()->getId()
181-
)->setReservedOrderId(
182-
'test01'
183-
)->setBillingAddress(
184-
$billingAddress
185-
)->setShippingAddress(
186-
$shippingAddress
187-
)->setCustomerEmail(
188-
'test@test.magento.com'
189-
)->addProduct(
190-
$product, $buyRequest
191-
);
139+
$quote
140+
->setCustomerIsGuest(true)
141+
->setStoreId($objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getId())
142+
->setReservedOrderId('test01')
143+
->setBillingAddress($billingAddress)
144+
->setShippingAddress($shippingAddres)
145+
->setCustomerEmail('test@test.magento.com')
146+
->addProduct($product, $buyRequest);
192147

193148
/** @var $rate \Magento\Quote\Model\Quote\Address\Rate */
194-
$rate = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Quote\Model\Quote\Address\Rate');
195-
$rate->setCode('freeshipping_freeshipping');
196-
$rate->getPrice(1);
149+
$rate = $objectManager->create('Magento\Quote\Model\Quote\Address\Rate');
150+
$rate
151+
->setCode('freeshipping_freeshipping')
152+
->getPrice(1);
153+
197154
$quote->getShippingAddress()->setShippingMethod('freeshipping_freeshipping');
198155
$quote->getShippingAddress()->addShippingRate($rate);
199-
200156
$quote->getPayment()->setMethod('checkmo');
201157
$quote->collectTotals();
202158
$quote->save();

0 commit comments

Comments
 (0)