Skip to content

Commit ea0cf63

Browse files
authored
Merge pull request #8002 from magento-l3/PR_25_NOV_2022
L3 bugfix delivery
2 parents 84e7dfa + e76ca5a commit ea0cf63

File tree

17 files changed

+163
-540
lines changed

17 files changed

+163
-540
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/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
}

0 commit comments

Comments
 (0)