|
7 | 7 | $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
8 | 8 | /** Create simple and bundle products for quote*/
|
9 | 9 | $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(); |
35 | 23 |
|
36 | 24 | $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(); |
62 | 38 |
|
63 | 39 | $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( |
94 | 52 | [
|
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( |
106 | 61 | [
|
107 | 62 | [
|
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, |
111 | 67 | 'delete' => '',
|
112 | 68 | 'position' => 0,
|
113 |
| - 'selection_price_type' => 0, |
114 |
| - 'selection_price_value' => 0.0, |
115 | 69 | 'option_id' => '',
|
116 |
| - 'selection_id' => '', |
117 |
| - 'is_default' => 1, |
118 | 70 | ],
|
| 71 | + ] |
| 72 | + ) |
| 73 | + ->setBundleSelectionsData( |
| 74 | + [ |
119 | 75 | [
|
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(); |
138 | 106 |
|
139 | 107 | //Load options
|
140 | 108 | $typeInstance = $product->getTypeInstance();
|
|
158 | 126 | );
|
159 | 127 | $product->setSkipCheckRequiredOption(true);
|
160 | 128 |
|
161 |
| - |
162 | 129 | $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]); |
167 | 131 | $billingAddress->setAddressType('billing');
|
168 | 132 |
|
169 | 133 | /** @var Magento\Quote\Model\Quote\Address $shippingAddress */
|
|
172 | 136 |
|
173 | 137 | /** @var \Magento\Quote\Model\Quote $quote */
|
174 | 138 | $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); |
192 | 147 |
|
193 | 148 | /** @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 | + |
197 | 154 | $quote->getShippingAddress()->setShippingMethod('freeshipping_freeshipping');
|
198 | 155 | $quote->getShippingAddress()->addShippingRate($rate);
|
199 |
| - |
200 | 156 | $quote->getPayment()->setMethod('checkmo');
|
201 | 157 | $quote->collectTotals();
|
202 | 158 | $quote->save();
|
|
0 commit comments