Skip to content

Commit d170563

Browse files
committed
Merge branch '2.3-develop' of github.com:magento/magento2ce into MC-19418
2 parents 809f0df + 89e28aa commit d170563

File tree

64 files changed

+1068
-307
lines changed

Some content is hidden

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

64 files changed

+1068
-307
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Bundle\Model\ResourceModel\Option;
77

8+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
9+
810
/**
911
* Bundle Options Resource Collection
1012
* @api
@@ -138,12 +140,10 @@ public function setPositionOrder()
138140

139141
/**
140142
* Append selection to options
141-
* stripBefore - indicates to reload
142-
* appendAll - indicates do we need to filter by saleable and required custom options
143143
*
144144
* @param \Magento\Bundle\Model\ResourceModel\Selection\Collection $selectionsCollection
145-
* @param bool $stripBefore
146-
* @param bool $appendAll
145+
* @param bool $stripBefore indicates to reload
146+
* @param bool $appendAll indicates do we need to filter by saleable and required custom options
147147
* @return \Magento\Framework\DataObject[]
148148
*/
149149
public function appendSelections($selectionsCollection, $stripBefore = false, $appendAll = true)
@@ -156,7 +156,9 @@ public function appendSelections($selectionsCollection, $stripBefore = false, $a
156156
foreach ($selectionsCollection->getItems() as $key => $selection) {
157157
$option = $this->getItemById($selection->getOptionId());
158158
if ($option) {
159-
if ($appendAll || $selection->isSalable() && !$selection->getRequiredOptions()) {
159+
if ($appendAll ||
160+
((int) $selection->getStatus()) === Status::STATUS_ENABLED && !$selection->getRequiredOptions()
161+
) {
160162
$selection->setOption($option);
161163
$option->addSelection($selection);
162164
} else {

app/code/Magento/Catalog/Block/Product/ImageFactory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ public function create(Product $product, string $imageId, array $attributes = nu
160160
);
161161
}
162162

163+
$attributes = $attributes === null ? [] : $attributes;
164+
163165
$data = [
164166
'data' => [
165167
'template' => 'Magento_Catalog::product/image_with_borders.phtml',

app/code/Magento/Catalog/Model/ProductAttributeGroupRepository.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
* Copyright © Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7+
declare(strict_types=1);
78

89
namespace Magento\Catalog\Model;
910

1011
use Magento\Framework\Exception\NoSuchEntityException;
1112
use Magento\Framework\Exception\StateException;
1213

14+
/**
15+
* Class \Magento\Catalog\Model\ProductAttributeGroupRepository
16+
*/
1317
class ProductAttributeGroupRepository implements \Magento\Catalog\Api\ProductAttributeGroupRepositoryInterface
1418
{
1519
/**
@@ -43,23 +47,29 @@ public function __construct(
4347
}
4448

4549
/**
46-
* {@inheritdoc}
50+
* @inheritdoc
4751
*/
4852
public function save(\Magento\Eav\Api\Data\AttributeGroupInterface $group)
4953
{
54+
/** @var \Magento\Catalog\Model\Product\Attribute\Group $group */
55+
$extensionAttributes = $group->getExtensionAttributes();
56+
if ($extensionAttributes) {
57+
$group->setSortOrder($extensionAttributes->getSortOrder());
58+
$group->setAttributeGroupCode($extensionAttributes->getAttributeGroupCode());
59+
}
5060
return $this->groupRepository->save($group);
5161
}
5262

5363
/**
54-
* {@inheritdoc}
64+
* @inheritdoc
5565
*/
5666
public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria)
5767
{
5868
return $this->groupRepository->getList($searchCriteria);
5969
}
6070

6171
/**
62-
* {@inheritdoc}
72+
* @inheritdoc
6373
*/
6474
public function get($groupId)
6575
{
@@ -75,7 +85,7 @@ public function get($groupId)
7585
}
7686

7787
/**
78-
* {@inheritdoc}
88+
* @inheritdoc
7989
*/
8090
public function deleteById($groupId)
8191
{
@@ -86,7 +96,7 @@ public function deleteById($groupId)
8696
}
8797

8898
/**
89-
* {@inheritdoc}
99+
* @inheritdoc
90100
*/
91101
public function delete(\Magento\Eav\Api\Data\AttributeGroupInterface $group)
92102
{

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,10 @@
422422
<waitForPageLoad stepKey="waitForPageOpened"/>
423423
<checkOption selector="{{ProductInWebsitesSection.website(website)}}" stepKey="selectWebsite"/>
424424
</actionGroup>
425+
<actionGroup name="unassignWebsiteFromProductActionGroup" extends="SelectProductInWebsitesActionGroup">
426+
<remove keyForRemoval="selectWebsite"/>
427+
<uncheckOption selector="{{ProductInWebsitesSection.website(website)}}" stepKey="unSelectWebsite" after="waitForPageOpened"/>
428+
</actionGroup>
425429

426430
<actionGroup name="AdminProductAddSpecialPrice">
427431
<annotations>

app/code/Magento/Catalog/Test/Mftf/Test/AdminGridPageNumberAfterSaveAndCloseActionTest.xml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@
1515
<title value="Checking Catalog grid page number after Save and Close action"/>
1616
<description value="Checking Catalog grid page number after Save and Close action"/>
1717
<severity value="MAJOR"/>
18-
<testCaseId value="MAGETWO-96164"/>
19-
<useCaseId value="MAGETWO-96127"/>
18+
<testCaseId value="MC-16472"/>
19+
<useCaseId value="MC-17332"/>
2020
<group value="Catalog"/>
21-
<skip>
22-
<issueId value="MC-17332"/>
23-
</skip>
2421
</annotations>
2522
<before>
2623
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>

app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptionsWithLongValuesTitle.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,6 @@
114114
</assertEquals>
115115
<moveMouseOver selector="{{AdminOrderItemsOrderedSection.productNameOptions}} dd" stepKey="hoverProduct"/>
116116
<waitForElementVisible selector="{{AdminOrderItemsOrderedSection.productNameOptions}} dd:nth-child(2)" stepKey="waitForCustomOptionValueFullName"/>
117-
<see selector="{{AdminOrderItemsOrderedSection.productNameOptions}}" userInput="Optisfvdklvfnkljvnfdklpvnfdjklfdvnjkvfdkjnvfdjkfvndj111 11Optisfvdklvfnkljvnfdklpvnfdjklfdvnjkvfdkjnvfdjkfvndj11111" stepKey="seeAdminOrderProductOptionValueDropdown1"/>
117+
<see selector="{{AdminOrderItemsOrderedSection.productNameOptions}}" userInput="Optisfvdklvfnkljvnfdklpvnfdjklfdvnjkvfdkjnvfdjkfvndj11111Optisfvdklvfnkljvnfdklpvnfdjklfdvnjkvfdkjnvfdjkfvndj11111" stepKey="seeAdminOrderProductOptionValueDropdown1"/>
118118
</test>
119119
</tests>

app/code/Magento/Catalog/view/frontend/templates/product/list/items.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ switch ($type = $block->getType()) {
170170
<?php if ($type == 'related' && $canItemsAddToCart) :?>
171171
<div class="block-actions">
172172
<?= $block->escapeHtml(__('Check items to add to the cart or')) ?>
173-
<button type="button" class="action select" role="button"><span><?= $block->escapeHtml(__('select all')) ?></span></button>
173+
<button type="button" class="action select" data-role="select-all"><span><?= $block->escapeHtml(__('select all')) ?></span></button>
174174
</div>
175175
<?php endif; ?>
176176
<div class="products wrapper grid products-grid products-<?= $block->escapeHtmlAttr($type) ?>">

app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,13 @@
3939
<?= $block->getChildHtml('form_bottom') ?>
4040
</form>
4141
</div>
42-
<script>
43-
require([
44-
'jquery',
45-
'priceBox'
46-
], function($){
47-
var dataPriceBoxSelector = '[data-role=priceBox]',
48-
dataProductIdSelector = '[data-product-id=<?= $block->escapeHtml($_product->getId()) ?>]',
49-
priceBoxes = $(dataPriceBoxSelector + dataProductIdSelector);
5042

51-
priceBoxes = priceBoxes.filter(function(index, elem){
52-
return !$(elem).find('.price-from').length;
53-
});
54-
55-
priceBoxes.priceBox({'priceConfig': <?= /* @noEscape */ $block->getJsonConfig() ?>});
56-
});
43+
<script type="text/x-magento-init">
44+
{
45+
"[data-role=priceBox][data-price-box=product-id-<?= $block->escapeHtml($_product->getId()) ?>]": {
46+
"priceBox": {
47+
"priceConfig": <?= /* @noEscape */ $block->getJsonConfig() ?>
48+
}
49+
}
50+
}
5751
</script>

app/code/Magento/Catalog/view/frontend/web/js/related-products.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ define([
1717
relatedProductsField: '#related-products-field', // Hidden input field that stores related products.
1818
selectAllMessage: $.mage.__('select all'),
1919
unselectAllMessage: $.mage.__('unselect all'),
20-
selectAllLink: '[role="button"]',
20+
selectAllLink: '[data-role="select-all"]',
2121
elementsSelector: '.item.product'
2222
},
2323

app/code/Magento/CatalogImportExport/Model/Import/Product/MediaGalleryProcessor.php

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,42 @@ private function initMediaGalleryResources()
284284
}
285285
}
286286

287+
/**
288+
* Get the last media position for each product from the given list
289+
*
290+
* @param int $storeId
291+
* @param array $productIds
292+
* @return array
293+
*/
294+
private function getLastMediaPositionPerProduct(int $storeId, array $productIds): array
295+
{
296+
$result = [];
297+
if ($productIds) {
298+
$productKeyName = $this->getProductEntityLinkField();
299+
// this result could be achieved by using GROUP BY. But there is no index on position column, therefore
300+
// it can be slower than the implementation below
301+
$positions = $this->connection->fetchAll(
302+
$this->connection
303+
->select()
304+
->from($this->mediaGalleryValueTableName, [$productKeyName, 'position'])
305+
->where("$productKeyName IN (?)", $productIds)
306+
->where('value_id is not null')
307+
->where('store_id = ?', $storeId)
308+
);
309+
// Make sure the result contains all product ids even if the product has no media files
310+
$result = array_fill_keys($productIds, 0);
311+
// Find the largest position for each product
312+
foreach ($positions as $record) {
313+
$productId = $record[$productKeyName];
314+
$result[$productId] = $result[$productId] < $record['position']
315+
? $record['position']
316+
: $result[$productId];
317+
}
318+
}
319+
320+
return $result;
321+
}
322+
287323
/**
288324
* Save media gallery data per store.
289325
*
@@ -301,24 +337,30 @@ private function processMediaPerStore(
301337
) {
302338
$multiInsertData = [];
303339
$dataForSkinnyTable = [];
340+
$lastMediaPositionPerProduct = $this->getLastMediaPositionPerProduct(
341+
$storeId,
342+
array_unique(array_merge(...array_values($valueToProductId)))
343+
);
344+
304345
foreach ($mediaGalleryData as $mediaGalleryRows) {
305346
foreach ($mediaGalleryRows as $insertValue) {
306-
foreach ($newMediaValues as $value_id => $values) {
347+
foreach ($newMediaValues as $valueId => $values) {
307348
if ($values['value'] == $insertValue['value']) {
308-
$insertValue['value_id'] = $value_id;
349+
$insertValue['value_id'] = $valueId;
309350
$insertValue[$this->getProductEntityLinkField()]
310351
= array_shift($valueToProductId[$values['value']]);
311-
unset($newMediaValues[$value_id]);
352+
unset($newMediaValues[$valueId]);
312353
break;
313354
}
314355
}
315356
if (isset($insertValue['value_id'])) {
357+
$productId = $insertValue[$this->getProductEntityLinkField()];
316358
$valueArr = [
317359
'value_id' => $insertValue['value_id'],
318360
'store_id' => $storeId,
319-
$this->getProductEntityLinkField() => $insertValue[$this->getProductEntityLinkField()],
361+
$this->getProductEntityLinkField() => $productId,
320362
'label' => $insertValue['label'],
321-
'position' => $insertValue['position'],
363+
'position' => $lastMediaPositionPerProduct[$productId] + $insertValue['position'],
322364
'disabled' => $insertValue['disabled'],
323365
];
324366
$multiInsertData[] = $valueArr;

0 commit comments

Comments
 (0)