Skip to content

Commit b58d40c

Browse files
Merge branch '2.3-develop' into MC-18071
2 parents 7234972 + 484cc98 commit b58d40c

File tree

89 files changed

+1549
-443
lines changed

Some content is hidden

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

89 files changed

+1549
-443
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/Category/Tree.php

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,16 @@
55
*/
66
namespace Magento\Catalog\Model\Category;
77

8+
use Magento\Catalog\Api\Data\CategoryTreeInterface;
9+
use Magento\Catalog\Api\Data\CategoryTreeInterfaceFactory;
10+
use Magento\Catalog\Model\Category;
11+
use Magento\Catalog\Model\ResourceModel\Category\Collection;
12+
use Magento\Catalog\Model\ResourceModel\Category\TreeFactory;
13+
use Magento\Framework\App\ObjectManager;
814
use Magento\Framework\Data\Tree\Node;
15+
use Magento\Framework\Exception\LocalizedException;
16+
use Magento\Framework\Exception\NoSuchEntityException;
17+
use Magento\Store\Model\StoreManagerInterface;
918

1019
/**
1120
* Retrieve category data represented in tree structure
@@ -18,54 +27,54 @@ class Tree
1827
protected $categoryTree;
1928

2029
/**
21-
* @var \Magento\Store\Model\StoreManagerInterface
30+
* @var StoreManagerInterface
2231
*/
2332
protected $storeManager;
2433

2534
/**
26-
* @var \Magento\Catalog\Model\ResourceModel\Category\Collection
35+
* @var Collection
2736
*/
2837
protected $categoryCollection;
2938

3039
/**
31-
* @var \Magento\Catalog\Api\Data\CategoryTreeInterfaceFactory
40+
* @var CategoryTreeInterfaceFactory
3241
*/
3342
protected $treeFactory;
3443

3544
/**
36-
* @var \Magento\Catalog\Model\ResourceModel\Category\TreeFactory
45+
* @var TreeFactory
3746
*/
3847
private $treeResourceFactory;
3948

4049
/**
4150
* @param \Magento\Catalog\Model\ResourceModel\Category\Tree $categoryTree
42-
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
43-
* @param \Magento\Catalog\Model\ResourceModel\Category\Collection $categoryCollection
44-
* @param \Magento\Catalog\Api\Data\CategoryTreeInterfaceFactory $treeFactory
45-
* @param \Magento\Catalog\Model\ResourceModel\Category\TreeFactory|null $treeResourceFactory
51+
* @param StoreManagerInterface $storeManager
52+
* @param Collection $categoryCollection
53+
* @param CategoryTreeInterfaceFactory $treeFactory
54+
* @param TreeFactory|null $treeResourceFactory
4655
*/
4756
public function __construct(
4857
\Magento\Catalog\Model\ResourceModel\Category\Tree $categoryTree,
49-
\Magento\Store\Model\StoreManagerInterface $storeManager,
50-
\Magento\Catalog\Model\ResourceModel\Category\Collection $categoryCollection,
51-
\Magento\Catalog\Api\Data\CategoryTreeInterfaceFactory $treeFactory,
52-
\Magento\Catalog\Model\ResourceModel\Category\TreeFactory $treeResourceFactory = null
58+
StoreManagerInterface $storeManager,
59+
Collection $categoryCollection,
60+
CategoryTreeInterfaceFactory $treeFactory,
61+
TreeFactory $treeResourceFactory = null
5362
) {
5463
$this->categoryTree = $categoryTree;
5564
$this->storeManager = $storeManager;
5665
$this->categoryCollection = $categoryCollection;
5766
$this->treeFactory = $treeFactory;
58-
$this->treeResourceFactory = $treeResourceFactory ?? \Magento\Framework\App\ObjectManager::getInstance()
59-
->get(\Magento\Catalog\Model\ResourceModel\Category\TreeFactory::class);
67+
$this->treeResourceFactory = $treeResourceFactory ?? ObjectManager::getInstance()
68+
->get(TreeFactory::class);
6069
}
6170

6271
/**
6372
* Get root node by category.
6473
*
65-
* @param \Magento\Catalog\Model\Category|null $category
74+
* @param Category|null $category
6675
* @return Node|null
67-
* @throws \Magento\Framework\Exception\LocalizedException
68-
* @throws \Magento\Framework\Exception\NoSuchEntityException
76+
* @throws LocalizedException
77+
* @throws NoSuchEntityException
6978
*/
7079
public function getRootNode($category = null)
7180
{
@@ -86,28 +95,28 @@ public function getRootNode($category = null)
8695
/**
8796
* Get node by category.
8897
*
89-
* @param \Magento\Catalog\Model\Category $category
98+
* @param Category $category
9099
* @return Node
91-
* @throws \Magento\Framework\Exception\LocalizedException
92-
* @throws \Magento\Framework\Exception\NoSuchEntityException
100+
* @throws LocalizedException
101+
* @throws NoSuchEntityException
93102
*/
94-
protected function getNode(\Magento\Catalog\Model\Category $category)
103+
protected function getNode(Category $category)
95104
{
96105
$nodeId = $category->getId();
97106
$categoryTree = $this->treeResourceFactory->create();
98107
$node = $categoryTree->loadNode($nodeId);
99108
$node->loadChildren();
100109
$this->prepareCollection();
101-
$this->categoryTree->addCollectionData($this->categoryCollection);
110+
$categoryTree->addCollectionData($this->categoryCollection);
102111
return $node;
103112
}
104113

105114
/**
106115
* Prepare category collection.
107116
*
108117
* @return void
109-
* @throws \Magento\Framework\Exception\LocalizedException
110-
* @throws \Magento\Framework\Exception\NoSuchEntityException
118+
* @throws LocalizedException
119+
* @throws NoSuchEntityException
111120
*/
112121
protected function prepareCollection()
113122
{
@@ -128,16 +137,16 @@ protected function prepareCollection()
128137
/**
129138
* Get tree by node.
130139
*
131-
* @param \Magento\Framework\Data\Tree\Node $node
140+
* @param Node $node
132141
* @param int $depth
133142
* @param int $currentLevel
134-
* @return \Magento\Catalog\Api\Data\CategoryTreeInterface
143+
* @return CategoryTreeInterface
135144
*/
136145
public function getTree($node, $depth = null, $currentLevel = 0)
137146
{
138-
/** @var \Magento\Catalog\Api\Data\CategoryTreeInterface[] $children */
147+
/** @var CategoryTreeInterface[] $children */
139148
$children = $this->getChildren($node, $depth, $currentLevel);
140-
/** @var \Magento\Catalog\Api\Data\CategoryTreeInterface $tree */
149+
/** @var CategoryTreeInterface $tree */
141150
$tree = $this->treeFactory->create();
142151
$tree->setId($node->getId())
143152
->setParentId($node->getParentId())
@@ -153,10 +162,10 @@ public function getTree($node, $depth = null, $currentLevel = 0)
153162
/**
154163
* Get node children.
155164
*
156-
* @param \Magento\Framework\Data\Tree\Node $node
165+
* @param Node $node
157166
* @param int $depth
158167
* @param int $currentLevel
159-
* @return \Magento\Catalog\Api\Data\CategoryTreeInterface[]|[]
168+
* @return CategoryTreeInterface[]|[]
160169
*/
161170
protected function getChildren($node, $depth, $currentLevel)
162171
{
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
/**
3+
* Plugin for \Magento\Catalog\Model\Category\DataProvider
4+
*
5+
* Copyright © Magento, Inc. All rights reserved.
6+
* See COPYING.txt for license details.
7+
*/
8+
9+
declare(strict_types=1);
10+
11+
namespace Magento\Catalog\Model\Plugin;
12+
13+
use Magento\Catalog\Model\Category\DataProvider;
14+
use Magento\Framework\Exception\NoSuchEntityException;
15+
16+
/**
17+
* Sets the default value for Category Design Layout if provided
18+
*/
19+
class SetPageLayoutDefaultValue
20+
{
21+
private $defaultValue;
22+
23+
/**
24+
* @param string $defaultValue
25+
*/
26+
public function __construct(string $defaultValue = "")
27+
{
28+
$this->defaultValue = $defaultValue;
29+
}
30+
31+
/**
32+
* Sets the default value for Category Design Layout in data provider if provided
33+
*
34+
* @param DataProvider $subject
35+
* @param array $result
36+
* @return array
37+
*
38+
* @throws NoSuchEntityException
39+
*/
40+
public function afterGetDefaultMetaData(DataProvider $subject, array $result): array
41+
{
42+
$currentCategory = $subject->getCurrentCategory();
43+
44+
if ($currentCategory && !$currentCategory->getId() && array_key_exists('page_layout', $result)) {
45+
$result['page_layout']['default'] = $this->defaultValue ?: null;
46+
}
47+
48+
return $result;
49+
}
50+
}

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/ActionGroup/AdminProductGridActionGroup.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,5 +400,6 @@
400400
<click selector="{{AdminProductGridSection.bulkActionOption('Delete')}}" stepKey="clickDeleteAction"/>
401401
<waitForElementVisible selector="{{AdminProductGridConfirmActionSection.ok}}" stepKey="waitForModalPopUp"/>
402402
<click selector="{{AdminProductGridConfirmActionSection.ok}}" stepKey="confirmProductDelete"/>
403+
<waitForPageLoad stepKey="waitForGridLoad"/>
403404
</actionGroup>
404405
</actionGroups>

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/etc/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@
7676
<type name="Magento\Customer\Model\ResourceModel\Visitor">
7777
<plugin name="catalogLog" type="Magento\Catalog\Model\Plugin\Log" />
7878
</type>
79+
<type name="Magento\Catalog\Model\Category\DataProvider">
80+
<plugin name="set_page_layout_default_value" type="Magento\Catalog\Model\Plugin\SetPageLayoutDefaultValue" />
81+
</type>
7982
<type name="Magento\Theme\Block\Html\Topmenu">
8083
<plugin name="catalogTopmenu" type="Magento\Catalog\Plugin\Block\Topmenu" />
8184
</type>

0 commit comments

Comments
 (0)