Skip to content

Commit 035d70d

Browse files
author
Olga Nakonechna
committed
Merge branch 'develop' of github.corp.magento.com:magento2/magento2ce into PR
2 parents 0e64324 + be02d0d commit 035d70d

File tree

48 files changed

+1259
-822
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1259
-822
lines changed

app/code/Magento/Bundle/Model/LinkManagement.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function __construct(
8787
*/
8888
public function getChildren($productSku, $optionId = null)
8989
{
90-
$product = $this->productRepository->get($productSku);
90+
$product = $this->productRepository->get($productSku, true);
9191
if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
9292
throw new InputException(__('Only implemented for bundle product'));
9393
}
@@ -111,7 +111,7 @@ public function getChildren($productSku, $optionId = null)
111111
public function addChildByProductSku($sku, $optionId, \Magento\Bundle\Api\Data\LinkInterface $linkedProduct)
112112
{
113113
/** @var \Magento\Catalog\Model\Product $product */
114-
$product = $this->productRepository->get($sku);
114+
$product = $this->productRepository->get($sku, true);
115115
return $this->addChild($product, $optionId, $linkedProduct);
116116
}
117117

@@ -124,7 +124,7 @@ public function saveChild(
124124
$sku,
125125
\Magento\Bundle\Api\Data\LinkInterface $linkedProduct
126126
) {
127-
$product = $this->productRepository->get($sku);
127+
$product = $this->productRepository->get($sku, true);
128128
if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
129129
throw new InputException(
130130
__('Product with specified sku: "%1" is not a bundle product', [$product->getSku()])
@@ -277,7 +277,7 @@ public function addChild(
277277
*/
278278
public function removeChild($sku, $optionId, $childSku)
279279
{
280-
$product = $this->productRepository->get($sku);
280+
$product = $this->productRepository->get($sku, true);
281281

282282
if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
283283
throw new InputException(__('Product with specified sku: %1 is not a bundle product', $sku));

app/code/Magento/Bundle/Model/OptionManagement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(
3737
*/
3838
public function save(\Magento\Bundle\Api\Data\OptionInterface $option)
3939
{
40-
$product = $this->productRepository->get($option->getSku());
40+
$product = $this->productRepository->get($option->getSku(), true);
4141
if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
4242
throw new InputException(__('Only implemented for bundle product'));
4343
}

app/code/Magento/Bundle/Model/OptionRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ protected function updateOptionSelection(
250250
*/
251251
private function getProduct($sku)
252252
{
253-
$product = $this->productRepository->get($sku);
253+
$product = $this->productRepository->get($sku, true);
254254
if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
255255
throw new InputException(__('Only implemented for bundle product'));
256256
}

app/code/Magento/Bundle/Model/Product/Attribute/Source/Price/Type.php

Lines changed: 0 additions & 45 deletions
This file was deleted.

app/code/Magento/Bundle/Model/Product/SaveHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function execute($entityType, $entity)
6464
$this->optionRepository->delete($option);
6565
}
6666

67-
$options = $entity->getExtensionAttributes()->getBundleProductOptions() ?: [];
67+
$options = $bundleProductOptions ?: [];
6868
foreach ($options as $option) {
6969
$option->setOptionId(null);
7070
$this->optionRepository->save($entity, $option);

app/code/Magento/Bundle/Model/Product/Type.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ public function getChildrenIds($parentId, $required = true)
247247
return $this->_bundleSelection->getChildrenIds($parentId, $required);
248248
}
249249

250-
/**
250+
/**
251251
* Retrieve parent ids array by required child
252252
*
253253
* @param int|array $childId

app/code/Magento/Bundle/Model/ResourceModel/Option/Collection.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,29 @@ public function setProductIdFilter($productId)
8585
'cpe.'.$linkField.' = main_table.parent_id',
8686
[]
8787
)->where(
88-
'cpe.entity_id = ?',
88+
"cpe.entity_id = ?",
8989
$productId
9090
);
9191

9292
return $this;
9393
}
9494

95+
/**
96+
* Set product link filter
97+
*
98+
* @param int $productLinkFieldValue
99+
*
100+
* @return $this
101+
*/
102+
public function setProductLinkFilter($productLinkFieldValue)
103+
{
104+
$this->getSelect()->where(
105+
'main_table.parent_id = ?',
106+
$productLinkFieldValue
107+
);
108+
return $this;
109+
}
110+
95111
/**
96112
* Sets order by position
97113
*

app/code/Magento/Bundle/Setup/UpgradeData.php

Lines changed: 119 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
*/
66
namespace Magento\Bundle\Setup;
77

8-
use Magento\Catalog\Model\Product;
8+
use Magento\Catalog\Api\Data\ProductAttributeInterface;
99
use Magento\Framework\Setup\ModuleContextInterface;
1010
use Magento\Framework\Setup\ModuleDataSetupInterface;
1111
use Magento\Framework\Setup\UpgradeDataInterface;
1212
use Magento\Eav\Setup\EavSetupFactory;
13+
use Magento\Eav\Setup\EavSetup;
1314

1415
class UpgradeData implements UpgradeDataInterface
1516
{
@@ -39,37 +40,125 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
3940
/** @var \Magento\Eav\Setup\EavSetup $eavSetup */
4041
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
4142

42-
$eavSetup->updateAttribute(Product::ENTITY, 'price_type', 'frontend_input', 'boolean');
43-
$eavSetup->updateAttribute(
44-
Product::ENTITY,
45-
'price_type',
46-
'source_model',
47-
'Magento\Bundle\Model\Product\Attribute\Source\Price\Type'
48-
);
49-
$eavSetup->updateAttribute(Product::ENTITY, 'sku_type', 'frontend_input', 'boolean');
50-
$eavSetup->updateAttribute(
51-
Product::ENTITY,
52-
'sku_type',
53-
'source_model',
54-
'Magento\Bundle\Model\Product\Attribute\Source\Price\Type'
55-
);
56-
$eavSetup->updateAttribute(Product::ENTITY, 'weight_type', 'frontend_input', 'boolean');
57-
$eavSetup->updateAttribute(
58-
Product::ENTITY,
59-
'weight_type',
60-
'source_model',
61-
'Magento\Bundle\Model\Product\Attribute\Source\Price\Type'
62-
);
63-
$eavSetup->updateAttribute(Product::ENTITY, 'shipment_type', 'frontend_input', 'select');
64-
$eavSetup->updateAttribute(Product::ENTITY, 'shipment_type', 'frontend_label', __('Ship Bundle Items'), 1);
65-
$eavSetup->updateAttribute(
66-
Product::ENTITY,
67-
'shipment_type',
68-
'source_model',
69-
'Magento\Bundle\Model\Product\Attribute\Source\Shipment\Type'
70-
);
43+
$eavSetup->addAttributeGroup(ProductAttributeInterface::ENTITY_TYPE_CODE, 'Default', 'Bundle Items', 16);
44+
45+
$this->upgradePriceType($eavSetup);
46+
$this->upgradeSkuType($eavSetup);
47+
$this->upgradeWeightType($eavSetup);
48+
$this->upgradeShipmentType($eavSetup);
7149
}
7250

7351
$setup->endSetup();
7452
}
53+
54+
/**
55+
* Upgrade Dynamic Price attribute
56+
*
57+
* @param EavSetup $eavSetup
58+
* @return void
59+
*/
60+
private function upgradePriceType(EavSetup $eavSetup)
61+
{
62+
$eavSetup->updateAttribute(
63+
ProductAttributeInterface::ENTITY_TYPE_CODE,
64+
'price_type',
65+
'frontend_input',
66+
'boolean',
67+
31
68+
);
69+
$eavSetup->updateAttribute(
70+
ProductAttributeInterface::ENTITY_TYPE_CODE,
71+
'price_type',
72+
'frontend_label',
73+
'Dynamic Price'
74+
);
75+
$eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'price_type', 'default_value', 0);
76+
}
77+
78+
/**
79+
* Upgrade Dynamic Sku attribute
80+
*
81+
* @param EavSetup $eavSetup
82+
* @return void
83+
*/
84+
private function upgradeSkuType(EavSetup $eavSetup)
85+
{
86+
$eavSetup->updateAttribute(
87+
ProductAttributeInterface::ENTITY_TYPE_CODE,
88+
'sku_type',
89+
'frontend_input',
90+
'boolean',
91+
21
92+
);
93+
$eavSetup->updateAttribute(
94+
ProductAttributeInterface::ENTITY_TYPE_CODE,
95+
'sku_type',
96+
'frontend_label',
97+
'Dynamic SKU'
98+
);
99+
$eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'sku_type', 'default_value', 0);
100+
$eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'sku_type', 'is_visible', 1);
101+
}
102+
103+
/**
104+
* Upgrade Dynamic Weight attribute
105+
*
106+
* @param EavSetup $eavSetup
107+
* @return void
108+
*/
109+
private function upgradeWeightType(EavSetup $eavSetup)
110+
{
111+
$eavSetup->updateAttribute(
112+
ProductAttributeInterface::ENTITY_TYPE_CODE,
113+
'weight_type',
114+
'frontend_input',
115+
'boolean',
116+
71
117+
);
118+
$eavSetup->updateAttribute(
119+
ProductAttributeInterface::ENTITY_TYPE_CODE,
120+
'weight_type',
121+
'frontend_label',
122+
'Dynamic Weight'
123+
);
124+
$eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'weight_type', 'default_value', 0);
125+
$eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'weight_type', 'is_visible', 1);
126+
}
127+
128+
/**
129+
* Upgrade Ship Bundle Items attribute
130+
*
131+
* @param EavSetup $eavSetup
132+
* @return void
133+
*/
134+
private function upgradeShipmentType(EavSetup $eavSetup)
135+
{
136+
$eavSetup->addAttributeToGroup(
137+
ProductAttributeInterface::ENTITY_TYPE_CODE,
138+
'Default',
139+
'Bundle Items',
140+
'shipment_type',
141+
1
142+
);
143+
$eavSetup->updateAttribute(
144+
ProductAttributeInterface::ENTITY_TYPE_CODE,
145+
'shipment_type',
146+
'frontend_input',
147+
'select'
148+
);
149+
$eavSetup->updateAttribute(
150+
ProductAttributeInterface::ENTITY_TYPE_CODE,
151+
'shipment_type',
152+
'frontend_label',
153+
'Ship Bundle Items'
154+
);
155+
$eavSetup->updateAttribute(
156+
ProductAttributeInterface::ENTITY_TYPE_CODE,
157+
'shipment_type',
158+
'source_model',
159+
'Magento\Bundle\Model\Product\Attribute\Source\Shipment\Type'
160+
);
161+
$eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'shipment_type', 'default_value', 0);
162+
$eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'shipment_type', 'is_visible', 1);
163+
}
75164
}

app/code/Magento/Bundle/Test/Unit/Model/Product/Attribute/Source/Price/TypeTest.php

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)