Skip to content

Commit e2ca453

Browse files
authored
Merge branch '2.4-develop' into Spartans_246_quality_graphql_mainlinepr
2 parents 9010796 + ea0cf63 commit e2ca453

File tree

60 files changed

+2050
-1847
lines changed

Some content is hidden

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

60 files changed

+2050
-1847
lines changed

app/code/Magento/AsynchronousOperations/Controller/Adminhtml/Notification/Dismiss.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
use Magento\AsynchronousOperations\Model\BulkNotificationManagement;
99
use Magento\Backend\App\Action\Context;
1010
use Magento\Backend\App\Action;
11-
use Magento\Framework\App\Action\HttpGetActionInterface;
11+
use Magento\Framework\App\Action\HttpPostActionInterface;
1212
use Magento\Framework\Controller\ResultFactory;
1313

1414
/**
1515
* Class Bulk Notification Dismiss Controller
1616
*/
17-
class Dismiss extends Action implements HttpGetActionInterface
17+
class Dismiss extends Action implements HttpPostActionInterface
1818
{
1919
/**
2020
* @var BulkNotificationManagement
@@ -56,7 +56,7 @@ public function execute()
5656
$isAcknowledged = $this->notificationManagement->acknowledgeBulks($bulkUuids);
5757

5858
/** @var \Magento\Framework\Controller\Result\Json $result */
59-
$result = $this->resultFactory->create(ResultFactory::TYPE_RAW);
59+
$result = $this->resultFactory->create(ResultFactory::TYPE_JSON)->setData(['']);
6060
if (!$isAcknowledged) {
6161
$result->setHttpResponseCode(400);
6262
}

app/code/Magento/AsynchronousOperations/Test/Unit/Controller/Adminhtml/Notification/DismissTest.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Magento\AsynchronousOperations\Model\BulkNotificationManagement;
1212
use Magento\Framework\App\RequestInterface;
1313
use Magento\Framework\Controller\Result\Json;
14-
use Magento\Framework\Controller\Result\Raw;
1514
use Magento\Framework\Controller\ResultFactory;
1615
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1716
use PHPUnit\Framework\MockObject\MockObject;
@@ -44,11 +43,6 @@ class DismissTest extends TestCase
4443
*/
4544
private $jsonResultMock;
4645

47-
/**
48-
* @var MockObject
49-
*/
50-
private $rawResultMock;
51-
5246
protected function setUp(): void
5347
{
5448
$objectManager = new ObjectManager($this);
@@ -84,10 +78,15 @@ public function testExecute()
8478

8579
$this->resultFactoryMock->expects($this->once())
8680
->method('create')
87-
->with(ResultFactory::TYPE_RAW, [])
88-
->willReturn($this->rawResultMock);
81+
->with(ResultFactory::TYPE_JSON, [])
82+
->willReturn($this->jsonResultMock);
83+
84+
$this->jsonResultMock->expects($this->once())
85+
->method('setData')
86+
->with([''])
87+
->willReturn($this->jsonResultMock);
8988

90-
$this->assertEquals($this->rawResultMock, $this->model->execute());
89+
$this->assertEquals($this->jsonResultMock, $this->model->execute());
9190
}
9291

9392
public function testExecuteSetsBadRequestResponseStatusIfBulkWasNotAcknowledgedCorrectly()
@@ -101,7 +100,12 @@ public function testExecuteSetsBadRequestResponseStatusIfBulkWasNotAcknowledgedC
101100

102101
$this->resultFactoryMock->expects($this->once())
103102
->method('create')
104-
->with(ResultFactory::TYPE_RAW, [])
103+
->with(ResultFactory::TYPE_JSON, [])
104+
->willReturn($this->jsonResultMock);
105+
106+
$this->jsonResultMock->expects($this->once())
107+
->method('setData')
108+
->with([''])
105109
->willReturn($this->jsonResultMock);
106110

107111
$this->notificationManagementMock->expects($this->once())

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

Lines changed: 491 additions & 392 deletions
Large diffs are not rendered by default.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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\CatalogImportExport\Model\Import\Product;
9+
10+
use Magento\Framework\Exception\LocalizedException;
11+
use Magento\Framework\Phrase;
12+
13+
class Skip extends LocalizedException
14+
{
15+
}

app/code/Magento/CatalogInventory/Model/ResourceModel/StockStatusFilter.php

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
use Magento\CatalogInventory\Api\Data\StockStatusInterface;
1111
use Magento\CatalogInventory\Api\StockConfigurationInterface;
1212
use Magento\CatalogInventory\Model\Stock;
13-
use Magento\CatalogInventory\Model\StockStatusApplierInterface;
1413
use Magento\Framework\App\ResourceConnection;
1514
use Magento\Framework\DB\Select;
16-
use Magento\Framework\App\ObjectManager;
1715

1816
/**
1917
* Generic in-stock status filter
@@ -32,25 +30,16 @@ class StockStatusFilter implements StockStatusFilterInterface
3230
*/
3331
private $stockConfiguration;
3432

35-
/**
36-
* @var StockStatusApplierInterface
37-
*/
38-
private $stockStatusApplier;
39-
4033
/**
4134
* @param ResourceConnection $resource
4235
* @param StockConfigurationInterface $stockConfiguration
43-
* @param StockStatusApplierInterface|null $stockStatusApplier
4436
*/
4537
public function __construct(
4638
ResourceConnection $resource,
47-
StockConfigurationInterface $stockConfiguration,
48-
?StockStatusApplierInterface $stockStatusApplier = null
39+
StockConfigurationInterface $stockConfiguration
4940
) {
5041
$this->resource = $resource;
5142
$this->stockConfiguration = $stockConfiguration;
52-
$this->stockStatusApplier = $stockStatusApplier
53-
?? ObjectManager::getInstance()->get(StockStatusApplierInterface::class);
5443
}
5544

5645
/**
@@ -79,13 +68,7 @@ public function execute(
7968
implode(' AND ', $joinCondition),
8069
[]
8170
);
82-
83-
if ($this->stockStatusApplier->hasSearchResultApplier()) {
84-
$select->columns(["{$stockStatusTableAlias}.stock_status AS is_salable"]);
85-
} else {
86-
$select->where("{$stockStatusTableAlias}.stock_status = ?", StockStatusInterface::STATUS_IN_STOCK);
87-
}
88-
71+
$select->where("{$stockStatusTableAlias}.stock_status = ?", StockStatusInterface::STATUS_IN_STOCK);
8972
return $select;
9073
}
9174
}

app/code/Magento/CatalogInventory/Model/StockStatusApplier.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
/**
1111
* Search Result Applier getters and setters
12+
*
13+
* @deprecated - as the implementation has been reverted during the fix of ACP2E-748
14+
* @see \Magento\InventoryCatalog\Plugin\Catalog\Model\ResourceModel\Product\CollectionPlugin
1215
*/
1316
class StockStatusApplier implements StockStatusApplierInterface
1417
{
@@ -23,6 +26,8 @@ class StockStatusApplier implements StockStatusApplierInterface
2326
* Set flag, if the request is originated from SearchResultApplier
2427
*
2528
* @param bool $status
29+
* @deprecated
30+
* @see \Magento\InventoryCatalog\Plugin\Catalog\Model\ResourceModel\Product\CollectionPlugin::beforeSetOrder
2631
*/
2732
public function setSearchResultApplier(bool $status): void
2833
{
@@ -33,6 +38,8 @@ public function setSearchResultApplier(bool $status): void
3338
* Get flag, if the request is originated from SearchResultApplier
3439
*
3540
* @return bool
41+
* @deprecated
42+
* @see \Magento\InventoryCatalog\Plugin\Catalog\Model\ResourceModel\Product\CollectionPlugin::beforeSetOrder
3643
*/
3744
public function hasSearchResultApplier() : bool
3845
{

app/code/Magento/CatalogInventory/Model/StockStatusApplierInterface.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
/**
1111
* Search Result Applier interface.
12+
*
13+
* @deprecated - as the implementation has been reverted during the fix of ACP2E-748
14+
* @see \Magento\InventoryCatalog\Plugin\Catalog\Model\ResourceModel\Product\CollectionPlugin
1215
*/
1316
interface StockStatusApplierInterface
1417
{
@@ -17,13 +20,17 @@ interface StockStatusApplierInterface
1720
* Set flag, if the request is originated from SearchResultApplier
1821
*
1922
* @param bool $status
23+
* @deprecated
24+
* @see \Magento\InventoryCatalog\Plugin\Catalog\Model\ResourceModel\Product\CollectionPlugin::beforeSetOrder
2025
*/
2126
public function setSearchResultApplier(bool $status): void;
2227

2328
/**
2429
* Get flag, if the request is originated from SearchResultApplier
2530
*
2631
* @return bool
32+
* @deprecated
33+
* @see \Magento\InventoryCatalog\Plugin\Catalog\Model\ResourceModel\Product\CollectionPlugin::beforeSetOrder
2734
*/
2835
public function hasSearchResultApplier() : bool;
2936
}

app/code/Magento/ConfigurableProduct/Model/Plugin/ProductRepositorySave.php

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function __construct(
4949
* @param ProductRepositoryInterface $subject
5050
* @param ProductInterface $product
5151
* @param bool $saveOptions
52-
* @return array
52+
* @return void
5353
* @throws InputException
5454
* @throws NoSuchEntityException
5555
*
@@ -59,34 +59,23 @@ public function beforeSave(
5959
ProductRepositoryInterface $subject,
6060
ProductInterface $product,
6161
$saveOptions = false
62-
): array {
63-
$result[] = $product;
64-
if ($product->getTypeId() !== Configurable::TYPE_CODE) {
65-
return $result;
66-
}
67-
62+
): void {
6863
$extensionAttributes = $product->getExtensionAttributes();
69-
if ($extensionAttributes === null) {
70-
return $result;
71-
}
72-
73-
$configurableLinks = (array) $extensionAttributes->getConfigurableProductLinks();
74-
$configurableOptions = (array) $extensionAttributes->getConfigurableProductOptions();
64+
if ($extensionAttributes !== null && $product->getTypeId() === Configurable::TYPE_CODE) {
65+
$configurableLinks = (array) $extensionAttributes->getConfigurableProductLinks();
66+
$configurableOptions = (array) $extensionAttributes->getConfigurableProductOptions();
7567

76-
if (empty($configurableLinks) && empty($configurableOptions)) {
77-
return $result;
78-
}
79-
80-
$attributeCodes = [];
81-
/** @var OptionInterface $configurableOption */
82-
foreach ($configurableOptions as $configurableOption) {
83-
$eavAttribute = $this->productAttributeRepository->get($configurableOption->getAttributeId());
84-
$attributeCode = $eavAttribute->getAttributeCode();
85-
$attributeCodes[] = $attributeCode;
68+
if (!empty($configurableLinks) || !empty($configurableOptions)) {
69+
$attributeCodes = [];
70+
/** @var OptionInterface $configurableOption */
71+
foreach ($configurableOptions as $configurableOption) {
72+
$eavAttribute = $this->productAttributeRepository->get($configurableOption->getAttributeId());
73+
$attributeCode = $eavAttribute->getAttributeCode();
74+
$attributeCodes[] = $attributeCode;
75+
}
76+
$this->validateProductLinks($attributeCodes, $configurableLinks);
77+
}
8678
}
87-
$this->validateProductLinks($attributeCodes, $configurableLinks);
88-
89-
return $result;
9079
}
9180

9281
/**

app/code/Magento/ConfigurableProduct/Test/Unit/Model/Plugin/ProductRepositorySaveTest.php

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,13 @@ protected function setUp(): void
113113
*/
114114
public function testBeforeSaveWhenProductIsSimple(): void
115115
{
116-
$this->product->expects(static::once())
116+
$this->product->expects(static::atMost(1))
117117
->method('getTypeId')
118118
->willReturn('simple');
119-
$this->product->expects(static::never())
119+
$this->product->expects(static::once())
120120
->method('getExtensionAttributes');
121121

122-
$this->assertEquals(
123-
$this->product,
124-
$this->plugin->beforeSave($this->productRepository, $this->product)[0]
125-
);
122+
$this->assertNull($this->plugin->beforeSave($this->productRepository, $this->product));
126123
}
127124

128125
/**
@@ -150,52 +147,7 @@ public function testBeforeSaveWithoutOptions(): void
150147
$this->productAttributeRepository->expects(static::never())
151148
->method('get');
152149

153-
$this->assertEquals(
154-
$this->product,
155-
$this->plugin->beforeSave($this->productRepository, $this->product)[0]
156-
);
157-
}
158-
159-
/**
160-
* Test saving a configurable product with same set of attribute values
161-
*
162-
* @return void
163-
*/
164-
public function testBeforeSaveWithLinks(): void
165-
{
166-
$this->expectException(InputException::class);
167-
$this->expectExceptionMessage('Products "5" and "4" have the same set of attribute values.');
168-
$links = [4, 5];
169-
$this->product->expects(static::once())
170-
->method('getTypeId')
171-
->willReturn(Configurable::TYPE_CODE);
172-
173-
$this->product->expects(static::once())
174-
->method('getExtensionAttributes')
175-
->willReturn($this->extensionAttributes);
176-
$this->extensionAttributes->expects(static::once())
177-
->method('getConfigurableProductOptions')
178-
->willReturn(null);
179-
$this->extensionAttributes->expects(static::once())
180-
->method('getConfigurableProductLinks')
181-
->willReturn($links);
182-
183-
$this->productAttributeRepository->expects(static::never())
184-
->method('get');
185-
186-
$product = $this->getMockBuilder(Product::class)
187-
->disableOriginalConstructor()
188-
->setMethods(['getData'])
189-
->getMock();
190-
191-
$this->productRepository->expects(static::exactly(2))
192-
->method('getById')
193-
->willReturn($product);
194-
195-
$product->expects(static::never())
196-
->method('getData');
197-
198-
$this->plugin->beforeSave($this->productRepository, $this->product);
150+
$this->assertNull($this->plugin->beforeSave($this->productRepository, $this->product));
199151
}
200152

201153
/**

0 commit comments

Comments
 (0)