Skip to content

Commit c1190ee

Browse files
committed
Merge remote-tracking branch 'origin/2.3-develop' into MAGETWO-83820
2 parents 0ba2720 + eb09566 commit c1190ee

File tree

420 files changed

+23807
-7509
lines changed

Some content is hidden

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

420 files changed

+23807
-7509
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/Bundle/Model/ResourceModel/Option/Collection.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab
2626
*/
2727
protected $_selectionsAppended = false;
2828

29+
/**
30+
* @var int[]
31+
*/
32+
private $productIds = [];
33+
2934
/**
3035
* Init model and resource model
3136
*
@@ -94,20 +99,34 @@ public function joinValues($storeId)
9499
*/
95100
public function setProductIdFilter($productId)
96101
{
102+
$this->productIds[] = $productId;
103+
97104
$productTable = $this->getTable('catalog_product_entity');
98105
$linkField = $this->getConnection()->getAutoIncrementField($productTable);
99106
$this->getSelect()->join(
100107
['cpe' => $productTable],
101108
'cpe.'.$linkField.' = main_table.parent_id',
102109
[]
103110
)->where(
104-
"cpe.entity_id = ?",
105-
$productId
111+
"cpe.entity_id = (?)",
112+
$this->productIds
106113
);
107114

108115
return $this;
109116
}
110117

118+
/**
119+
* Clear product id's after load to insure valid future usage of collection.
120+
*
121+
* @return $this
122+
*/
123+
protected function _afterLoad()
124+
{
125+
$this->productIds = [];
126+
127+
return parent::_afterLoad();
128+
}
129+
111130
/**
112131
* Set product link filter
113132
*

app/code/Magento/BundleGraphQl/Model/BundleProductTypeResolver.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\BundleGraphQl\Model;
89

9-
use Magento\Framework\GraphQl\Config\Data\TypeResolverInterface;
10+
use Magento\Framework\GraphQl\Query\Resolver\TypeResolverInterface;
1011

1112
/**
1213
* {@inheritdoc}
@@ -16,10 +17,11 @@ class BundleProductTypeResolver implements TypeResolverInterface
1617
/**
1718
* {@inheritdoc}
1819
*/
19-
public function resolveType(array $data)
20+
public function resolveType(array $data) : string
2021
{
2122
if (isset($data['type_id']) && $data['type_id'] == 'bundle') {
2223
return 'BundleProduct';
2324
}
25+
return '';
2426
}
2527
}

app/code/Magento/BundleGraphQl/Model/Plugin/Model/Resolver/Products/DataProvider/ProductPlugin.php

Lines changed: 0 additions & 52 deletions
This file was deleted.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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\BundleGraphQl\Model\Resolver;
9+
10+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
11+
use Magento\BundleGraphQl\Model\Resolver\Links\Collection;
12+
use Magento\Framework\GraphQl\Config\Element\Field;
13+
use Magento\Framework\GraphQl\Query\Resolver\Value;
14+
use Magento\Framework\GraphQl\Query\Resolver\ValueFactory;
15+
use Magento\Framework\GraphQl\Query\ResolverInterface;
16+
17+
/**
18+
* {@inheritdoc}
19+
*/
20+
class BundleItemLinks implements ResolverInterface
21+
{
22+
/**
23+
* @var Collection
24+
*/
25+
private $linkCollection;
26+
27+
/**
28+
* @var ValueFactory
29+
*/
30+
private $valueFactory;
31+
32+
/**
33+
* @param Collection $linkCollection
34+
* @param ValueFactory $valueFactory
35+
*/
36+
public function __construct(
37+
Collection $linkCollection,
38+
ValueFactory $valueFactory
39+
) {
40+
$this->linkCollection = $linkCollection;
41+
$this->valueFactory = $valueFactory;
42+
}
43+
44+
/**
45+
* {@inheritDoc}
46+
*/
47+
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) : Value
48+
{
49+
if (!isset($value['option_id']) || !isset($value['parent_id'])) {
50+
$result = function () {
51+
return null;
52+
};
53+
return $this->valueFactory->create($result);
54+
}
55+
$this->linkCollection->addIdFilters((int)$value['option_id'], (int)$value['parent_id']);
56+
$result = function () use ($value) {
57+
return $this->linkCollection->getLinksForOptionId((int)$value['option_id']);
58+
};
59+
60+
return $this->valueFactory->create($result);
61+
}
62+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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\BundleGraphQl\Model\Resolver;
9+
10+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
11+
use Magento\Bundle\Model\Product\Type;
12+
use Magento\BundleGraphQl\Model\Resolver\Options\Collection;
13+
use Magento\Catalog\Api\Data\ProductInterface;
14+
use Magento\Framework\EntityManager\MetadataPool;
15+
use Magento\Framework\GraphQl\Config\Element\Field;
16+
use Magento\Framework\GraphQl\Query\Resolver\Value;
17+
use Magento\Framework\GraphQl\Query\Resolver\ValueFactory;
18+
use Magento\Framework\GraphQl\Query\ResolverInterface;
19+
20+
/**
21+
* {@inheritdoc}
22+
*/
23+
class BundleItems implements ResolverInterface
24+
{
25+
/**
26+
* @var Collection
27+
*/
28+
private $bundleOptionCollection;
29+
30+
/**
31+
* @var ValueFactory
32+
*/
33+
private $valueFactory;
34+
35+
/**
36+
* @var MetadataPool
37+
*/
38+
private $metdataPool;
39+
40+
/**
41+
* @param Collection $bundleOptionCollection
42+
* @param ValueFactory $valueFactory
43+
* @param MetadataPool $metdataPool
44+
*/
45+
public function __construct(
46+
Collection $bundleOptionCollection,
47+
ValueFactory $valueFactory,
48+
MetadataPool $metdataPool
49+
) {
50+
$this->bundleOptionCollection = $bundleOptionCollection;
51+
$this->valueFactory = $valueFactory;
52+
$this->metdataPool = $metdataPool;
53+
}
54+
55+
/**
56+
* Fetch and format bundle option items.
57+
*
58+
* {@inheritDoc}
59+
*/
60+
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) : Value
61+
{
62+
$linkField = $this->metdataPool->getMetadata(ProductInterface::class)->getLinkField();
63+
if ($value['type_id'] !== Type::TYPE_CODE
64+
|| !isset($value[$linkField])
65+
|| !isset($value[ProductInterface::SKU])
66+
) {
67+
$result = function () {
68+
return null;
69+
};
70+
return $this->valueFactory->create($result);
71+
}
72+
73+
$this->bundleOptionCollection->addParentFilterData(
74+
(int)$value[$linkField],
75+
(int)$value['entity_id'],
76+
$value[ProductInterface::SKU]
77+
);
78+
79+
$result = function () use ($value, $linkField) {
80+
return $this->bundleOptionCollection->getOptionsByParentId((int)$value[$linkField]);
81+
};
82+
83+
return $this->valueFactory->create($result);
84+
}
85+
}

0 commit comments

Comments
 (0)