Skip to content

Commit 980e971

Browse files
MarianaMariana
authored andcommitted
Merge branch 'MAGETWO-94099' into mpi-forwardport-0309
2 parents 22a246f + 97d681f commit 980e971

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/WebsitesTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ class WebsitesTest extends AbstractModifierTest
7474
*/
7575
protected $storeViewMock;
7676

77+
/**
78+
* @inheritdoc
79+
*/
7780
protected function setUp()
7881
{
7982
parent::setUp();
@@ -90,14 +93,11 @@ protected function setUp()
9093
->disableOriginalConstructor()
9194
->getMock();
9295
$this->websiteRepositoryMock = $this->getMockBuilder(\Magento\Store\Api\WebsiteRepositoryInterface::class)
93-
->setMethods(['getList', 'getDefault'])
96+
->setMethods(['getList'])
9497
->getMockForAbstractClass();
9598
$this->websiteRepositoryMock->expects($this->any())
9699
->method('getDefault')
97100
->willReturn($this->websiteMock);
98-
$this->websiteRepositoryMock->expects($this->any())
99-
->method('getList')
100-
->willReturn([$this->websiteMock, $this->secondWebsiteMock]);
101101
$this->groupRepositoryMock = $this->getMockBuilder(\Magento\Store\Api\GroupRepositoryInterface::class)
102102
->setMethods(['getList'])
103103
->getMockForAbstractClass();
@@ -111,8 +111,10 @@ protected function setUp()
111111
->method('getWebsiteIds')
112112
->willReturn($this->assignedWebsites);
113113
$this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
114-
->setMethods(['isSingleStoreMode'])
114+
->setMethods(['isSingleStoreMode', 'getWesites'])
115115
->getMockForAbstractClass();
116+
$this->storeManagerMock->method('getWebsites')
117+
->willReturn([$this->websiteMock, $this->secondWebsiteMock]);
116118
$this->storeManagerMock->expects($this->any())
117119
->method('isSingleStoreMode')
118120
->willReturn(false);

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Websites.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function __construct(
8989
}
9090

9191
/**
92-
* {@inheritdoc}
92+
* @inheritdoc
9393
* @since 101.0.0
9494
*/
9595
public function modifyData(array $data)
@@ -117,7 +117,7 @@ public function modifyData(array $data)
117117
}
118118

119119
/**
120-
* {@inheritdoc}
120+
* @inheritdoc
121121
* @since 101.0.0
122122
*/
123123
public function modifyMeta(array $meta)
@@ -175,9 +175,11 @@ protected function getFieldsForFieldset()
175175
$label = __('Websites');
176176

177177
$defaultWebsiteId = $this->websiteRepository->getDefault()->getId();
178+
$isOnlyOneWebsiteAvailable = count($websitesList) === 1;
178179
foreach ($websitesList as $website) {
179180
$isChecked = in_array($website['id'], $websiteIds)
180-
|| ($defaultWebsiteId == $website['id'] && $isNewProduct);
181+
|| ($defaultWebsiteId == $website['id'] && $isNewProduct)
182+
|| $isOnlyOneWebsiteAvailable;
181183
$children[$website['id']] = [
182184
'arguments' => [
183185
'data' => [
@@ -397,8 +399,9 @@ protected function getWebsitesList()
397399
$this->websitesList = [];
398400
$groupList = $this->groupRepository->getList();
399401
$storesList = $this->storeRepository->getList();
402+
$websiteList = $this->storeManager->getWebsites(true);
400403

401-
foreach ($this->websiteRepository->getList() as $website) {
404+
foreach ($websiteList as $website) {
402405
$websiteId = $website->getId();
403406
if (!$websiteId) {
404407
continue;

0 commit comments

Comments
 (0)