53 $bundleProductOptions = [
55 "title" =>
"test option",
62 'is_default' =>
false,
73 "type_id" =>
"bundle",
75 'attribute_set_id' => 4,
76 "custom_attributes" => [
78 "attribute_code" =>
"price_type",
82 "attribute_code" =>
"price_view",
86 "extension_attributes" => [
87 "bundle_product_options" => $bundleProductOptions,
94 $this->assertEquals(50,
$response[
'price']);
98 $resultBundleProductOptions
100 $this->assertTrue(isset($resultBundleProductOptions[0][
"product_links"][0][
"sku"]));
101 $this->assertEquals(
'simple', $resultBundleProductOptions[0][
"product_links"][0][
"sku"]);
107 $resultBundleProductOptions
109 $this->assertTrue(isset($resultBundleProductOptions[0][
"product_links"][0][
"sku"]));
110 $this->assertEquals(
'simple', $resultBundleProductOptions[0][
"product_links"][0][
"sku"]);
123 $bundleProductOptions[0][
'type'] =
'select';
125 $bundleProductOptions[0][
'product_links'][0][
'sku'] =
'simple2';
126 $bundleProductOptions[0][
'product_links'][0][
'qty'] = 2;
127 $bundleProductOptions[0][
'product_links'][0][
'price'] = 10;
128 $bundleProductOptions[0][
'product_links'][0][
'price_type'] = 1;
135 $this->assertEquals(
'simple2',
$bundleOptions[0][
'product_links'][0][
'sku']);
136 $this->assertEquals(2,
$bundleOptions[0][
'product_links'][0][
'qty']);
137 $this->assertEquals(10,
$bundleOptions[0][
'product_links'][0][
'price']);
138 $this->assertEquals(1,
$bundleOptions[0][
'product_links'][0][
'price_type']);
151 $bundleProductOptions[0][
'type'] =
'select';
159 $this->assertEquals(
'simple',
$bundleOptions[0][
'product_links'][0][
'sku']);
160 $this->assertEquals(1,
$bundleOptions[0][
'product_links'][0][
'qty']);
161 $this->assertEquals(20,
$bundleOptions[0][
'product_links'][0][
'price']);
162 $this->assertEquals(1,
$bundleOptions[0][
'product_links'][0][
'price_type']);
174 $existingSelectionId = $bundleProductOptions[0][
'product_links'][0][
'id'];
177 unset($bundleProductOptions[0][
'product_links']);
184 $this->assertEquals(
'simple',
$bundleOptions[0][
'product_links'][0][
'sku']);
185 $this->assertEquals(1,
$bundleOptions[0][
'product_links'][0][
'qty']);
186 $this->assertEquals($existingSelectionId,
$bundleOptions[0][
'product_links'][0][
'id']);
187 $this->assertEquals(20,
$bundleOptions[0][
'product_links'][0][
'price']);
188 $this->assertEquals(1,
$bundleOptions[0][
'product_links'][0][
'price_type']);
201 $bundleProductOptions[0][
'product_links'][] = [
206 "is_default" =>
false,
212 $this->assertEquals(
'simple',
$bundleOptions[0][
'product_links'][0][
'sku']);
213 $this->assertEquals(
'simple2',
$bundleOptions[0][
'product_links'][1][
'sku']);
214 $this->assertEquals(2,
$bundleOptions[0][
'product_links'][1][
'qty']);
215 $this->assertGreaterThan(
231 $oldOptionId = $bundleProductOptions[0][
'option_id'];
233 $bundleProductOptions[0] = [
234 'title' =>
'new option',
243 "is_default" =>
false,
250 $updatedProduct = $this->
getProduct(self::BUNDLE_PRODUCT_ID);
255 $this->assertGreaterThan($oldOptionId,
$bundleOptions[0][
'option_id']);
257 $this->assertEquals(
'simple2',
$bundleOptions[0][
'product_links'][0][
'sku']);
258 $this->assertEquals(2,
$bundleOptions[0][
'product_links'][0][
'qty']);
284 $product[
"extension_attributes"][
"bundle_product_options"] = $bundleProductOptions;
295 $bundleProductOptions = [
297 "title" =>
"test option",
298 "type" =>
"checkbox",
304 "is_default" =>
true,
316 "type_id" =>
"bundle",
317 'attribute_set_id' => 4,
318 "custom_attributes" => [
320 'attribute_code' =>
'price_type',
324 "attribute_code" =>
"price_view",
328 "extension_attributes" => [
329 "bundle_product_options" => $bundleProductOptions,
337 $resultBundleProductOptions
339 $this->assertTrue(isset($resultBundleProductOptions[0][
"product_links"][0][
"sku"]));
340 $this->assertEquals(
'simple', $resultBundleProductOptions[0][
"product_links"][0][
"sku"]);
341 $this->assertTrue(isset(
$response[
'custom_attributes']));
343 $this->assertTrue(isset($customAttributes[
'price_type']));
344 $this->assertEquals(\
Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC, $customAttributes[
'price_type']);
345 $this->assertTrue(isset($customAttributes[
'price_view']));
346 $this->assertEquals(1, $customAttributes[
'price_view']);
357 $bundleProductOptions = [
359 "title" =>
"test option",
360 "type" =>
"checkbox",
368 "is_default" =>
true,
378 "type_id" =>
"bundle",
380 'attribute_set_id' => 4,
381 "custom_attributes" => [
383 'attribute_code' =>
'price_type',
387 "attribute_code" =>
"price_view",
391 "extension_attributes" => [
392 "bundle_product_options" => $bundleProductOptions,
397 $resultBundleProductOptions
399 $this->assertEquals(
'simple', $resultBundleProductOptions[0][
"product_links"][0][
"sku"]);
400 $this->assertTrue(isset(
$response[
'custom_attributes']));
402 $this->assertTrue(isset($customAttributes[
'price_type']));
403 $this->assertEquals(\
Magento\Bundle\Model\Product\Price::PRICE_TYPE_FIXED, $customAttributes[
'price_type']);
404 $this->assertTrue(isset($customAttributes[
'price_view']));
405 $this->assertEquals(1, $customAttributes[
'price_view']);
411 $convertedCustomAttribute = [];
412 foreach ($customAttributes as $customAttribute) {
413 $convertedCustomAttribute[$customAttribute[
'attribute_code']] = $customAttribute[
'value'];
415 return $convertedCustomAttribute;
428 'resourcePath' => self::RESOURCE_PATH .
'/' . $productSku,
434 'operation' => self::SERVICE_NAME .
'Get',
460 'operation' => self::SERVICE_NAME .
'Save',
476 $resourcePath = self::RESOURCE_PATH .
'/' . $productSku;
479 'resourcePath' => $resourcePath,
485 'operation' => self::SERVICE_NAME .
'deleteById',
501 if (isset(
$product[
'custom_attributes'])) {
503 if (
$product[
'custom_attributes'][
$i][
'attribute_code'] ==
'category_ids' 504 && !is_array(
$product[
'custom_attributes'][
$i][
'value'])
506 $product[
'custom_attributes'][
$i][
'value'] = [
""];
510 $resourcePath = self::RESOURCE_PATH .
'/' .
$product[
'sku'];
513 'resourcePath' => $resourcePath,
519 'operation' => self::SERVICE_NAME .
'Save',
testUpdateBundleModifyExistingOptionOnly()
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)
setBundleProductOptions(&$product, $bundleProductOptions)
testUpdateProductWithoutBundleOptions()
convertCustomAttributes($customAttributes)
createDynamicBundleProduct()
const EXTENSION_ATTRIBUTES_KEY
getBundleProductOptions($product)
testUpdateBundleAddAndDeleteOption()
createFixedPriceBundleProduct()
testUpdateBundleModifyExistingSelection()
testUpdateBundleAddSelection()
deleteProductBySku($productSku)
static getObjectManager()