Skip to content

Commit 67cf4b7

Browse files
author
Elena Marchenko
committed
Merge branch 'MAGETWO-43491' of github.corp.magento.com:magento-mpi/magento2ce into MAGETWO-46343
2 parents ecc9511 + 6383835 commit 67cf4b7

File tree

7 files changed

+125
-18
lines changed

7 files changed

+125
-18
lines changed

app/code/Magento/Catalog/Model/Product/Type/AbstractType.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,12 @@ protected function _prepareOptions(\Magento\Framework\DataObject $buyRequest, $p
574574
{
575575
$transport = new \StdClass();
576576
$transport->options = [];
577+
$options = null;
577578
if ($product->getHasOptions()) {
578-
foreach ($product->getOptions() as $option) {
579+
$options = $product->getOptions();
580+
}
581+
if ($options !== null) {
582+
foreach ($options as $option) {
579583
/* @var $option \Magento\Catalog\Model\Product\Option */
580584
$group = $option->groupFactory($option->getType())
581585
->setOption($option)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Ui\Component\Form\Element;
8+
9+
class MultiSelect extends Select
10+
{
11+
const NAME = 'multiselect';
12+
13+
const DEFAULT_SIZE = 6;
14+
15+
/**
16+
* @inheritDoc
17+
*/
18+
public function prepare()
19+
{
20+
$config['size'] = self::DEFAULT_SIZE;
21+
$this->setData('config', array_replace_recursive((array)$this->getData('config'), $config));
22+
parent::prepare();
23+
}
24+
}

dev/tests/functional/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"require": {
3-
"magento/mtf": "1.0.0-rc37",
3+
"magento/mtf": "1.0.0-rc38",
44
"php": "~5.5.0|~5.6.0|~7.0.0",
55
"phpunit/phpunit": "4.1.0",
66
"phpunit/phpunit-selenium": ">=1.2"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2015 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="../../../../../vendor/magento/mtf/Magento/Mtf/TestRunner/etc/testRunner.xsd">
10+
<rule scope="testcase">
11+
<allow>
12+
<tag group="test_type" value="3rd_party_test" />
13+
</allow>
14+
</rule>
15+
<rule scope="variation">
16+
<allow>
17+
<tag group="test_type" value="3rd_party_test" />
18+
</allow>
19+
</rule>
20+
</config>

dev/tests/integration/testsuite/Magento/CatalogImportExport/_files/product_export_data.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
require dirname(dirname(__DIR__)) . '/Store/_files/second_store.php';
99
require dirname(dirname(__DIR__)) . '/Catalog/_files/products_with_multiselect_attribute.php';
1010

11-
$productModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Product');
11+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
12+
13+
$productModel = $objectManager->create('Magento\Catalog\Model\Product');
1214

1315
$customOptions = [
1416
1 => [
@@ -57,4 +59,17 @@
5759
[$product->getId() => ['position' => 1]]
5860
);
5961

60-
$product->setOptions($customOptions)->save();
62+
$options = [];
63+
64+
/** @var \Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory $customOptionFactory */
65+
$customOptionFactory = $objectManager->create('Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory');
66+
67+
foreach ($customOptions as $option) {
68+
/** @var \Magento\Catalog\Api\Data\ProductCustomOptionInterface $option */
69+
$option = $customOptionFactory->create(['data' => $option]);
70+
$option->setProductSku($productModel->getSku());
71+
72+
$options[] = $option;
73+
}
74+
75+
$productModel->setOptions($options)->save();

dev/tests/integration/testsuite/Magento/Quote/Model/QuoteManagementTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class QuoteManagementTest extends \PHPUnit_Framework_TestCase
1717
*/
1818
public function testSubmit()
1919
{
20-
$this->markTestSkipped('Skipped because of MAGETWO-47215');
2120
/**
2221
* Preconditions:
2322
* Load quote with Bundle product that has at least to child products

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

Lines changed: 58 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333
->setCategoryIds([2])
3434
->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1])
3535
->save();
36-
36+
$productRepository = $objectManager->get(Magento\Catalog\Api\ProductRepositoryInterface::class);
37+
/**
38+
* @var \Magento\Catalog\Model\Product $product
39+
*/
3740
$product = $objectManager->create('Magento\Catalog\Model\Product');
3841
$product
3942
->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE)
@@ -96,24 +99,66 @@
9699
]
97100
],
98101
]
99-
)
102+
)->setCustomAttributes([
103+
"price_type" => [
104+
'attribute_code' => 'price_type',
105+
'value' => \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC
106+
],
107+
"price_view" => [
108+
"attribute_code" => "price_view",
109+
"value" => "1",
110+
],
111+
])
100112
->setCanSaveBundleSelections(true)
101-
->setAffectBundleProductSelections(true)
102-
->save();
113+
->setHasOptions(false)
114+
->setAffectBundleProductSelections(true);
115+
if ($product->getBundleOptionsData()) {
116+
$options = [];
117+
foreach ($product->getBundleOptionsData() as $key => $optionData) {
118+
if (!(bool)$optionData['delete']) {
119+
$option = $objectManager->create('Magento\Bundle\Api\Data\OptionInterfaceFactory')
120+
->create(['data' => $optionData]);
121+
$option->setSku($product->getSku());
122+
$option->setOptionId(null);
103123

104-
//Load options
105-
$typeInstance = $product->getTypeInstance();
106-
$typeInstance->setStoreFilter($product->getStoreId(), $product);
107-
$optionCollection = $typeInstance->getOptionsCollection($product);
108-
$selectionCollection = $typeInstance->getSelectionsCollection($typeInstance->getOptionsIds($product), $product);
124+
$links = [];
125+
$bundleLinks = $product->getBundleSelectionsData();
126+
if (!empty($bundleLinks[$key])) {
127+
foreach ($bundleLinks[$key] as $linkData) {
128+
if (!(bool)$linkData['delete']) {
129+
/** @var \Magento\Bundle\Api\Data\LinkInterface$link */
130+
$link = $objectManager->create('Magento\Bundle\Api\Data\LinkInterfaceFactory')
131+
->create(['data' => $linkData]);
132+
$linkProduct = $productRepository->getById($linkData['product_id']);
133+
$link->setSku($linkProduct->getSku());
134+
$link->setQty($linkData['selection_qty']);
135+
if (isset($linkData['selection_can_change_qty'])) {
136+
$link->setCanChangeQuantity($linkData['selection_can_change_qty']);
137+
}
138+
$links[] = $link;
139+
}
140+
}
141+
$option->setProductLinks($links);
142+
$options[] = $option;
143+
}
144+
}
145+
}
146+
$extension = $product->getExtensionAttributes();
147+
$extension->setBundleProductOptions($options);
148+
$product->setExtensionAttributes($extension);
149+
}
150+
$productRepository->save($product);
109151

152+
$product = $productRepository->get($product->getSku());
110153
$bundleOptions = [];
111154
$bundleOptionsQty = [];
112155
/** @var $option \Magento\Bundle\Model\Option */
113-
foreach ($optionCollection as $option) {
114-
/** @var $selection \Magento\Bundle\Model\Selection */
115-
foreach ($selectionCollection as $selection) {
116-
$bundleOptions[$option->getId()][] = $selection->getSelectionId();
156+
foreach ($product->getExtensionAttributes()->getBundleProductOptions() as $option) {
157+
foreach ($option->getProductLinks() as $selection) {
158+
/**
159+
* @var \Magento\Bundle\Api\Data\LinkInterface $selection
160+
*/
161+
$bundleOptions[$option->getId()][] = $selection->getId();
117162
$bundleOptionsQty[$option->getId()][] = 1;
118163
}
119164
}

0 commit comments

Comments
 (0)