Skip to content

Commit 31c7a79

Browse files
committed
Merge remote-tracking branch 'origin/2.3-develop' into MAGETWO-82055
2 parents 8e890b9 + b18ce4a commit 31c7a79

File tree

24 files changed

+435
-174
lines changed

24 files changed

+435
-174
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@ public function getPopupTitle()
7777
$messageCount = count($this->_messages->getUnread());
7878
if ($messageCount > 1) {
7979
return __('You have %1 new system messages', $messageCount);
80-
} else {
81-
return __('You have %1 new system message', $messageCount);
8280
}
81+
return __('You have %1 new system message', $messageCount);
8382
}
8483

8584
/**

app/code/Magento/AdminNotification/Block/Window.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,9 @@ protected function _getLatestItem()
9898
{
9999
if ($this->_latestItem == null) {
100100
$items = array_values($this->_criticalCollection->getItems());
101+
$this->_latestItem = false;
101102
if (count($items)) {
102103
$this->_latestItem = $items[0];
103-
} else {
104-
$this->_latestItem = false;
105104
}
106105
}
107106
return $this->_latestItem;

app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,9 +626,8 @@ protected function _getCustomerGroupById(
626626
): string {
627627
if ($allGroups !== 0) {
628628
return ImportAdvancedPricing::VALUE_ALL_GROUPS;
629-
} else {
630-
return $this->_groupRepository->getById($groupId)->getCode();
631629
}
630+
return $this->_groupRepository->getById($groupId)->getCode();
632631
}
633632

634633
/**

app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,8 @@ protected function deleteProductTierPrices(array $listSku, $table)
482482
$this->addRowError(ValidatorInterface::ERROR_SKU_IS_EMPTY, 0);
483483
return false;
484484
}
485-
} else {
486-
return false;
487485
}
486+
return false;
488487
}
489488

490489
/**

app/code/Magento/Analytics/Model/Config/Backend/Enabled.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,7 @@ public function afterSave()
6767
try {
6868
if ($this->isValueChanged()) {
6969
$enabled = $this->getData('value');
70-
71-
if ($enabled) {
72-
$this->subscriptionHandler->processEnabled();
73-
} else {
74-
$this->subscriptionHandler->processDisabled();
75-
}
70+
$enabled ? $this->subscriptionHandler->processEnabled() : $this->subscriptionHandler->processDisabled();
7671
}
7772
} catch (\Exception $e) {
7873
$this->_logger->error($e->getMessage());

app/code/Magento/Authorization/Model/ResourceModel/Role.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $role)
6868
}
6969

7070
if (!$role->getTreeLevel()) {
71+
$treeLevel = 0;
7172
if ($role->getPid() > 0) {
7273
$select = $this->getConnection()->select()->from(
7374
$this->getMainTable(),
@@ -79,8 +80,6 @@ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $role)
7980
$binds = ['pid' => (int)$role->getPid()];
8081

8182
$treeLevel = $this->getConnection()->fetchOne($select, $binds);
82-
} else {
83-
$treeLevel = 0;
8483
}
8584

8685
$role->setTreeLevel($treeLevel + 1);
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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\CatalogGraphQl\Model\Resolver\Product;
9+
10+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
11+
use Magento\Catalog\Model\Product;
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+
use Magento\CatalogGraphQl\Model\Resolver\Product\Websites\Collection;
17+
18+
/**
19+
* Retrieves the websites information object
20+
*/
21+
class Websites implements ResolverInterface
22+
{
23+
/**
24+
* @var ValueFactory
25+
*/
26+
private $valueFactory;
27+
28+
/**
29+
* @var Collection
30+
*/
31+
private $productWebsitesCollection;
32+
33+
/**
34+
* @param ValueFactory $valueFactory
35+
* @param Collection $productWebsitesCollection
36+
*/
37+
public function __construct(
38+
ValueFactory $valueFactory,
39+
Collection $productWebsitesCollection
40+
) {
41+
$this->valueFactory = $valueFactory;
42+
$this->productWebsitesCollection = $productWebsitesCollection;
43+
}
44+
45+
/**
46+
* {@inheritDoc}
47+
*/
48+
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) : Value
49+
{
50+
if (!isset($value['entity_id'])) {
51+
$result = function () {
52+
return null;
53+
};
54+
return $this->valueFactory->create($result);
55+
}
56+
$this->productWebsitesCollection->addIdFilters((int)$value['entity_id']);
57+
$result = function () use ($value) {
58+
return $this->productWebsitesCollection->getWebsiteForProductId((int)$value['entity_id']);
59+
};
60+
61+
return $this->valueFactory->create($result);
62+
}
63+
}
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
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\CatalogGraphQl\Model\Resolver\Product\Websites;
9+
10+
use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
11+
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
12+
use Magento\Store\Model\ResourceModel\Website\Collection as WebsiteCollection;
13+
use Magento\Store\Model\ResourceModel\Website\CollectionFactory as WebsiteCollectionFactory;
14+
15+
/**
16+
* Collection to fetch websites data at resolution time.
17+
*/
18+
class Collection
19+
{
20+
/**
21+
* @var WebsiteCollection
22+
*/
23+
private $websiteCollection;
24+
25+
/**
26+
* @var ProductCollection
27+
*/
28+
private $productCollection;
29+
30+
/**
31+
* @var int[]
32+
*/
33+
private $productIds = [];
34+
35+
/**
36+
* @var array
37+
*/
38+
private $websites = [];
39+
40+
/**
41+
* @param WebsiteCollectionFactory $websiteCollectionFactory
42+
* @param ProductCollectionFactory $productCollectionFactory
43+
*/
44+
public function __construct(
45+
WebsiteCollectionFactory $websiteCollectionFactory,
46+
ProductCollectionFactory $productCollectionFactory
47+
) {
48+
$this->websiteCollection = $websiteCollectionFactory->create();
49+
$this->productCollection = $productCollectionFactory->create();
50+
}
51+
52+
/**
53+
* Add product and id filter to filter for fetch.
54+
*
55+
* @param int $productId
56+
* @return void
57+
*/
58+
public function addIdFilters(int $productId) : void
59+
{
60+
if (!in_array($productId, $this->productIds)) {
61+
$this->productIds[] = $productId;
62+
}
63+
}
64+
65+
/**
66+
* Retrieve website for passed in product id.
67+
*
68+
* @param int $productId
69+
* @return array
70+
*/
71+
public function getWebsiteForProductId(int $productId) : array
72+
{
73+
$websiteList = $this->fetch();
74+
75+
if (!isset($websiteList[$productId])) {
76+
return [];
77+
}
78+
79+
return $websiteList[$productId];
80+
}
81+
82+
/**
83+
* Fetch website data and return in array format. Keys for links will be their product Ids.
84+
*
85+
* @return array
86+
*/
87+
private function fetch() : array
88+
{
89+
if (empty($this->productIds) || !empty($this->websites)) {
90+
return $this->websites;
91+
}
92+
93+
$selectUnique = $this->productCollection->getConnection()->select()->from(
94+
['product_website' => $this->productCollection->getResource()->getTable('catalog_product_website')]
95+
)->where(
96+
'product_website.product_id IN (?)',
97+
$this->productIds
98+
)->where(
99+
'website_id > ?',
100+
0
101+
)->group('website_id');
102+
103+
$websiteDataUnique = $this->productCollection->getConnection()->fetchAll($selectUnique);
104+
105+
$websiteIds = [];
106+
foreach ($websiteDataUnique as $websiteData) {
107+
$websiteIds[] = $websiteData['website_id'];
108+
}
109+
$this->websiteCollection->addIdFilter($websiteIds);
110+
111+
$siteData = $this->websiteCollection->getItems();
112+
113+
$select = $this->productCollection->getConnection()->select()->from(
114+
['product_website' => $this->productCollection->getResource()->getTable('catalog_product_website')]
115+
)->where(
116+
'product_website.product_id IN (?)',
117+
$this->productIds
118+
)->where(
119+
'website_id > ?',
120+
0
121+
);
122+
123+
foreach ($this->productCollection->getConnection()->fetchAll($select) as $row) {
124+
$website = $siteData[$row['website_id']];
125+
$this->websites[$row['product_id']][$row['website_id']] = [
126+
'id' => $row['website_id'],
127+
'name' => $website->getData('name'),
128+
'code' => $website->getData('code'),
129+
'sort_order' => $website->getData('sort_order'),
130+
'default_group_id' => $website->getData('default_group_id'),
131+
'is_default' => $website->getData('is_default'),
132+
];
133+
}
134+
return $this->websites;
135+
}
136+
}

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Product/CollectionProcessor/RequiredColumnsProcessor.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public function process(
3030
$collection->addAttributeToSelect('special_price_from');
3131
$collection->addAttributeToSelect('special_price_to');
3232
$collection->addAttributeToSelect('tax_class_id');
33-
$collection->addWebsiteNamesToResult();
3433

3534
return $collection;
3635
}

app/code/Magento/CatalogGraphQl/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"magento/framework": "*"
1414
},
1515
"suggest": {
16-
"magento/module-graph-ql": "100.0.*"
16+
"magento/module-graph-ql": "*",
17+
"magento/module-store-graph-ql": "*"
1718
},
1819
"license": [
1920
"OSL-3.0",

0 commit comments

Comments
 (0)