Skip to content

Commit 7c33307

Browse files
committed
Merge remote-tracking branch 'epam/EPAM-PR-40' into EPAM-PR-38-39-40
2 parents e1827c6 + 813c215 commit 7c33307

File tree

40 files changed

+789
-64
lines changed

40 files changed

+789
-64
lines changed

app/code/Magento/Bundle/Block/Adminhtml/Sales/Order/Items/Renderer.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ public function getChildren($item)
100100
}
101101

102102
/**
103+
* Check if item can be shipped separately
104+
*
103105
* @param mixed $item
104106
* @return bool
105107
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
@@ -136,6 +138,8 @@ public function isShipmentSeparately($item = null)
136138
}
137139

138140
/**
141+
* Check if child items calculated
142+
*
139143
* @param mixed $item
140144
* @return bool
141145
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
@@ -174,6 +178,8 @@ public function isChildCalculated($item = null)
174178
}
175179

176180
/**
181+
* Retrieve selection attributes values
182+
*
177183
* @param mixed $item
178184
* @return mixed|null
179185
*/
@@ -191,6 +197,8 @@ public function getSelectionAttributes($item)
191197
}
192198

193199
/**
200+
* Retrieve order item options array
201+
*
194202
* @return array
195203
*/
196204
public function getOrderOptions()
@@ -212,6 +220,8 @@ public function getOrderOptions()
212220
}
213221

214222
/**
223+
* Retrieve order item
224+
*
215225
* @return mixed
216226
*/
217227
public function getOrderItem()
@@ -223,6 +233,8 @@ public function getOrderItem()
223233
}
224234

225235
/**
236+
* Get html info for item
237+
*
226238
* @param mixed $item
227239
* @return string
228240
*/
@@ -245,6 +257,8 @@ public function getValueHtml($item)
245257
}
246258

247259
/**
260+
* Check if we can show price info for this item
261+
*
248262
* @param object $item
249263
* @return bool
250264
*/

app/code/Magento/Bundle/view/adminhtml/templates/sales/invoice/create/items/renderer.phtml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,17 @@
2828
<?php endif; ?>
2929

3030
<?php foreach ($items as $_item): ?>
31+
<?php
32+
$shipTogether = ($_item->getOrderItem()->getProductType() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) ?
33+
!$_item->getOrderItem()->isShipSeparately() : !$_item->getOrderItem()->getParentItem()->isShipSeparately()
34+
?>
3135
<?php $block->setPriceDataObject($_item) ?>
3236
<?php if ($_item->getOrderItem()->getParentItem()): ?>
37+
<?php
38+
if ($shipTogether) {
39+
continue;
40+
}
41+
?>
3342
<?php $attributes = $block->getSelectionAttributes($_item) ?>
3443
<?php if ($_prevOptionId != $attributes['option_id']): ?>
3544
<tr>
@@ -60,14 +69,14 @@
6069
</td>
6170
<?php endif; ?>
6271
<td class="col-price">
63-
<?php if ($block->canShowPriceInfo($_item)): ?>
72+
<?php if ($block->canShowPriceInfo($_item) || $shipTogether): ?>
6473
<?= $block->getColumnHtml($_item, 'price') ?>
6574
<?php else: ?>
6675
&nbsp;
6776
<?php endif; ?>
6877
</td>
6978
<td class="col-qty">
70-
<?php if ($block->canShowPriceInfo($_item)): ?>
79+
<?php if ($block->canShowPriceInfo($_item) || $shipTogether): ?>
7180
<table class="qty-table">
7281
<tr>
7382
<th><?= /* @escapeNotVerified */ __('Ordered') ?></th>
@@ -116,7 +125,7 @@
116125
<?php endif; ?>
117126
</td>
118127
<td class="col-qty-invoice">
119-
<?php if ($block->canShowPriceInfo($_item)): ?>
128+
<?php if ($block->canShowPriceInfo($_item) || $shipTogether): ?>
120129
<?php if ($block->canEditQty()) : ?>
121130
<input type="text"
122131
class="input-text admin__control-text qty-input"

app/code/Magento/Catalog/Model/Product/Option/Repository.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use Magento\Framework\App\ObjectManager;
1515

1616
/**
17+
* Product custom options repository
18+
*
1719
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1820
*/
1921
class Repository implements \Magento\Catalog\Api\ProductCustomOptionRepositoryInterface
@@ -83,7 +85,7 @@ public function __construct(
8385
}
8486

8587
/**
86-
* {@inheritdoc}
88+
* @inheritdoc
8789
*/
8890
public function getList($sku)
8991
{
@@ -92,7 +94,7 @@ public function getList($sku)
9294
}
9395

9496
/**
95-
* {@inheritdoc}
97+
* @inheritdoc
9698
*/
9799
public function getProductOptions(ProductInterface $product, $requiredOnly = false)
98100
{
@@ -104,7 +106,7 @@ public function getProductOptions(ProductInterface $product, $requiredOnly = fal
104106
}
105107

106108
/**
107-
* {@inheritdoc}
109+
* @inheritdoc
108110
*/
109111
public function get($sku, $optionId)
110112
{
@@ -117,7 +119,7 @@ public function get($sku, $optionId)
117119
}
118120

119121
/**
120-
* {@inheritdoc}
122+
* @inheritdoc
121123
*/
122124
public function delete(\Magento\Catalog\Api\Data\ProductCustomOptionInterface $entity)
123125
{
@@ -126,7 +128,7 @@ public function delete(\Magento\Catalog\Api\Data\ProductCustomOptionInterface $e
126128
}
127129

128130
/**
129-
* {@inheritdoc}
131+
* @inheritdoc
130132
*/
131133
public function duplicate(
132134
\Magento\Catalog\Api\Data\ProductInterface $product,
@@ -142,7 +144,7 @@ public function duplicate(
142144
}
143145

144146
/**
145-
* {@inheritdoc}
147+
* @inheritdoc
146148
*/
147149
public function save(\Magento\Catalog\Api\Data\ProductCustomOptionInterface $option)
148150
{
@@ -184,7 +186,7 @@ public function save(\Magento\Catalog\Api\Data\ProductCustomOptionInterface $opt
184186
}
185187

186188
/**
187-
* {@inheritdoc}
189+
* @inheritdoc
188190
*/
189191
public function deleteByIdentifier($sku, $optionId)
190192
{
@@ -209,8 +211,8 @@ public function deleteByIdentifier($sku, $optionId)
209211
/**
210212
* Mark original values for removal if they are absent among new values
211213
*
212-
* @param $newValues array
213-
* @param $originalValues \Magento\Catalog\Model\Product\Option\Value[]
214+
* @param array $newValues
215+
* @param \Magento\Catalog\Model\Product\Option\Value[] $originalValues
214216
* @return array
215217
*/
216218
protected function markRemovedValues($newValues, $originalValues)
@@ -234,6 +236,8 @@ protected function markRemovedValues($newValues, $originalValues)
234236
}
235237

236238
/**
239+
* Get hydrator pool
240+
*
237241
* @return \Magento\Framework\EntityManager\HydratorPool
238242
* @deprecated 101.0.0
239243
*/

app/code/Magento/Catalog/Model/Product/Option/SaveHandler.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,19 @@ public function __construct(
2828
}
2929

3030
/**
31+
* Perform action on relation/extension attribute
32+
*
3133
* @param object $entity
3234
* @param array $arguments
3335
* @return \Magento\Catalog\Api\Data\ProductInterface|object
3436
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
3537
*/
3638
public function execute($entity, $arguments = [])
3739
{
40+
if ($entity->getOptionsSaved()) {
41+
return $entity;
42+
}
43+
3844
$options = $entity->getOptions();
3945
$optionIds = [];
4046

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Plugin\Model\Product\Option;
9+
10+
/**
11+
* Plugin for updating product 'has_options' and 'required_options' attributes
12+
*/
13+
class UpdateProductCustomOptionsAttributes
14+
{
15+
/**
16+
* @var \Magento\Catalog\Api\ProductRepositoryInterface
17+
*/
18+
private $productRepository;
19+
20+
/**
21+
* @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
22+
*/
23+
public function __construct(\Magento\Catalog\Api\ProductRepositoryInterface $productRepository)
24+
{
25+
$this->productRepository = $productRepository;
26+
}
27+
28+
/**
29+
* Update product 'has_options' and 'required_options' attributes after option save
30+
*
31+
* @param \Magento\Catalog\Api\ProductCustomOptionRepositoryInterface $subject
32+
* @param \Magento\Catalog\Api\Data\ProductCustomOptionInterface $option
33+
*
34+
* @return \Magento\Catalog\Api\Data\ProductCustomOptionInterface
35+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
36+
*/
37+
public function afterSave(
38+
\Magento\Catalog\Api\ProductCustomOptionRepositoryInterface $subject,
39+
\Magento\Catalog\Api\Data\ProductCustomOptionInterface $option
40+
) {
41+
$product = $this->productRepository->get($option->getProductSku());
42+
if (!$product->getHasOptions() ||
43+
($option->getIsRequire() && !$product->getRequiredOptions())) {
44+
$product->setCanSaveCustomOptions(true);
45+
$product->setOptionsSaved(true);
46+
$currentOptions = array_filter($product->getOptions(), function ($iOption) use ($option) {
47+
return $option->getOptionId() != $iOption->getOptionId();
48+
});
49+
$currentOptions[] = $option;
50+
$product->setOptions($currentOptions);
51+
$product->save();
52+
}
53+
54+
return $option;
55+
}
56+
}

app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
<requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity>
3636
<requiredEntity type="custom_attribute_array">CustomAttributeCategoryIds</requiredEntity>
3737
</entity>
38+
<entity name="ApiSimpleProductWithCustomPrice" type="product" extends="ApiSimpleProduct">
39+
<data key="price">100</data>
40+
</entity>
3841
<entity name="ApiSimpleProductUpdateDescription" type="product2">
3942
<requiredEntity type="custom_attribute">ApiProductDescription</requiredEntity>
4043
<requiredEntity type="custom_attribute">ApiProductShortDescription</requiredEntity>

app/code/Magento/Catalog/etc/webapi_rest/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@
1919
<plugin name="get_catalog_category_product_index_table_name" type="Magento\Catalog\Model\Indexer\Category\Product\Plugin\TableResolver"/>
2020
<plugin name="get_catalog_product_price_index_table_name" type="Magento\Catalog\Model\Indexer\Product\Price\Plugin\TableResolver"/>
2121
</type>
22+
<type name="Magento\Catalog\Api\ProductCustomOptionRepositoryInterface">
23+
<plugin name="updateProductCustomOptionsAttributes" type="Magento\Catalog\Plugin\Model\Product\Option\UpdateProductCustomOptionsAttributes"/>
24+
</type>
2225
</config>

app/code/Magento/Catalog/etc/webapi_soap/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@
1919
<plugin name="get_catalog_category_product_index_table_name" type="Magento\Catalog\Model\Indexer\Category\Product\Plugin\TableResolver"/>
2020
<plugin name="get_catalog_product_price_index_table_name" type="Magento\Catalog\Model\Indexer\Product\Price\Plugin\TableResolver"/>
2121
</type>
22+
<type name="Magento\Catalog\Api\ProductCustomOptionRepositoryInterface">
23+
<plugin name="updateProductCustomOptionsAttributes" type="Magento\Catalog\Plugin\Model\Product\Option\UpdateProductCustomOptionsAttributes"/>
24+
</type>
2225
</config>

app/code/Magento/Checkout/Block/Cart/Sidebar.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,14 @@ public function getConfig()
8282
'baseUrl' => $this->getBaseUrl(),
8383
'minicartMaxItemsVisible' => $this->getMiniCartMaxItemsCount(),
8484
'websiteId' => $this->_storeManager->getStore()->getWebsiteId(),
85-
'maxItemsToDisplay' => $this->getMaxItemsToDisplay()
85+
'maxItemsToDisplay' => $this->getMaxItemsToDisplay(),
86+
'storeId' => $this->_storeManager->getStore()->getId()
8687
];
8788
}
8889

8990
/**
91+
* Get serialized config
92+
*
9093
* @return string
9194
* @since 100.2.0
9295
*/
@@ -96,6 +99,8 @@ public function getSerializedConfig()
9699
}
97100

98101
/**
102+
* Get image html template
103+
*
99104
* @return string
100105
*/
101106
public function getImageHtmlTemplate()
@@ -130,6 +135,7 @@ public function getShoppingCartUrl()
130135
*
131136
* @return string
132137
* @codeCoverageIgnore
138+
* @SuppressWarnings(PHPMD.RequestAwareBlockMethod)
133139
*/
134140
public function getUpdateItemQtyUrl()
135141
{
@@ -141,6 +147,7 @@ public function getUpdateItemQtyUrl()
141147
*
142148
* @return string
143149
* @codeCoverageIgnore
150+
* @SuppressWarnings(PHPMD.RequestAwareBlockMethod)
144151
*/
145152
public function getRemoveItemUrl()
146153
{
@@ -210,6 +217,7 @@ private function getMiniCartMaxItemsCount()
210217

211218
/**
212219
* Returns maximum cart items to display
220+
*
213221
* This setting regulates how many items will be displayed in minicart
214222
*
215223
* @return int

app/code/Magento/Checkout/CustomerData/Cart.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
/**
1212
* Cart source
13+
*
14+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
1315
*/
1416
class Cart extends \Magento\Framework\DataObject implements SectionSourceInterface
1517
{
@@ -98,7 +100,8 @@ public function getSectionData()
98100
'items' => $this->getRecentItems(),
99101
'extra_actions' => $this->layout->createBlock(\Magento\Catalog\Block\ShortcutButtons::class)->toHtml(),
100102
'isGuestCheckoutAllowed' => $this->isGuestCheckoutAllowed(),
101-
'website_id' => $this->getQuote()->getStore()->getWebsiteId()
103+
'website_id' => $this->getQuote()->getStore()->getWebsiteId(),
104+
'storeId' => $this->getQuote()->getStore()->getStoreId()
102105
];
103106
}
104107

0 commit comments

Comments
 (0)