Skip to content

Commit b70e129

Browse files
committed
Merge remote-tracking branch 'mainline/2.3-develop' into MAGETWO-89292-SDL
2 parents 941fd68 + 85afb2a commit b70e129

File tree

36 files changed

+969
-278
lines changed

36 files changed

+969
-278
lines changed

app/code/Magento/AdminNotification/Block/System/Messages.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,34 @@ class Messages extends \Magento\Backend\Block\Template
1616

1717
/**
1818
* @var \Magento\Framework\Json\Helper\Data
19+
* @deprecated
1920
*/
2021
protected $jsonHelper;
2122

23+
/**
24+
* @var \Magento\Framework\Serialize\Serializer\Json
25+
*/
26+
private $serializer;
27+
2228
/**
2329
* @param \Magento\Backend\Block\Template\Context $context
2430
* @param \Magento\AdminNotification\Model\ResourceModel\System\Message\Collection\Synchronized $messages
2531
* @param \Magento\Framework\Json\Helper\Data $jsonHelper
2632
* @param array $data
33+
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
2734
*/
2835
public function __construct(
2936
\Magento\Backend\Block\Template\Context $context,
3037
\Magento\AdminNotification\Model\ResourceModel\System\Message\Collection\Synchronized $messages,
3138
\Magento\Framework\Json\Helper\Data $jsonHelper,
32-
array $data = []
39+
array $data = [],
40+
\Magento\Framework\Serialize\Serializer\Json $serializer = null
3341
) {
3442
$this->jsonHelper = $jsonHelper;
3543
parent::__construct($context, $data);
3644
$this->_messages = $messages;
45+
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
46+
->get(\Magento\Framework\Serialize\Serializer\Json::class);
3747
}
3848

3949
/**
@@ -117,7 +127,7 @@ protected function _getMessagesUrl()
117127
*/
118128
public function getSystemMessageDialogJson()
119129
{
120-
return $this->jsonHelper->jsonEncode(
130+
return $this->serializer->serialize(
121131
[
122132
'systemMessageDialog' => [
123133
'buttons' => [],

app/code/Magento/AdminNotification/Controller/Adminhtml/System/Message/ListAction.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
*/
77
namespace Magento\AdminNotification\Controller\Adminhtml\System\Message;
88

9+
use Magento\Framework\Controller\ResultFactory;
10+
911
class ListAction extends \Magento\Backend\App\AbstractAction
1012
{
1113
/**
@@ -15,6 +17,7 @@ class ListAction extends \Magento\Backend\App\AbstractAction
1517

1618
/**
1719
* @var \Magento\Framework\Json\Helper\Data
20+
* @deprecated
1821
*/
1922
protected $jsonHelper;
2023

@@ -41,7 +44,7 @@ public function __construct(
4144
}
4245

4346
/**
44-
* @return void
47+
* @return \Magento\Framework\Controller\Result\Json
4548
*/
4649
public function execute()
4750
{
@@ -63,6 +66,9 @@ public function execute()
6366
. 'Please refresh the web page to clear the notice alert.',
6467
];
6568
}
66-
$this->getResponse()->representJson($this->jsonHelper->jsonEncode($result));
69+
/** @var \Magento\Framework\Controller\Result\Json $resultJson */
70+
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
71+
$resultJson->setData($result);
72+
return $resultJson;
6773
}
6874
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
* @method Category setUrlPath(string $urlPath)
3333
* @method Category getSkipDeleteChildren()
3434
* @method Category setSkipDeleteChildren(boolean $value)
35+
* @method Category setChangedProductIds(array $categoryIds) Set products ids that inserted or deleted for category
36+
* @method array getChangedProductIds() Get products ids that inserted or deleted for category
3537
*
3638
* @SuppressWarnings(PHPMD.LongVariable)
3739
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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\Model\Category\Product;
9+
10+
/**
11+
* Resolver to get product positions by ids assigned to specific category
12+
*/
13+
class PositionResolver extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
14+
{
15+
/**
16+
* Initialize resource model
17+
*
18+
* @return void
19+
*/
20+
protected function _construct()
21+
{
22+
$this->_init('catalog_product_entity', 'entity_id');
23+
}
24+
25+
/**
26+
* Get category product positions
27+
*
28+
* @param int $categoryId
29+
* @return array
30+
*/
31+
public function getPositions(int $categoryId): array
32+
{
33+
$connection = $this->getConnection();
34+
35+
$select = $connection->select()->from(
36+
['cpe' => $this->getTable('catalog_product_entity')],
37+
'entity_id'
38+
)->joinLeft(
39+
['ccp' => $this->getTable('catalog_category_product')],
40+
'ccp.product_id=cpe.entity_id'
41+
)->where(
42+
'ccp.category_id = ?',
43+
$categoryId
44+
)->order(
45+
'ccp.position ' . \Magento\Framework\DB\Select::SQL_ASC
46+
);
47+
48+
return array_flip($connection->fetchCol($select));
49+
}
50+
}

0 commit comments

Comments
 (0)