Skip to content

Commit a757fb5

Browse files
Merge branch 'develop' of https://github.corp.magento.com/magento2/magento2ce into MAGETWO-52010
2 parents d17f266 + c3199e7 commit a757fb5

File tree

79 files changed

+992
-325
lines changed

Some content is hidden

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

79 files changed

+992
-325
lines changed

app/code/Magento/Backend/Block/System/Store/Edit/Form/Group.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,12 @@ protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
135135
'disabled' => $groupModel->isReadOnly()
136136
]
137137
);
138-
139138
if ($this->_coreRegistry->registry('store_action') == 'edit') {
140-
$stores = $this->_storeFactory->create()->getCollection()->addGroupFilter(
141-
$groupModel->getId()
142-
)->toOptionArray();
139+
$storeActive = 1;
140+
$stores = $this->_storeFactory->create()->getCollection()
141+
->addGroupFilter($groupModel->getId())
142+
->addStatusFilter($storeActive)
143+
->toOptionArray();
143144
$fieldset->addField(
144145
'group_default_store_id',
145146
'select',

app/code/Magento/Backend/Block/System/Store/Edit/Form/Store.php

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public function __construct(
5050
*
5151
* @param \Magento\Framework\Data\Form $form
5252
* @return void
53-
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
5453
*/
5554
protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
5655
{
@@ -75,27 +74,7 @@ protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
7574
'disabled' => $storeModel->isReadOnly()
7675
]
7776
);
78-
if ($storeModel->getId() && $storeModel->getGroup()->getDefaultStoreId() == $storeModel->getId()) {
79-
if ($storeModel->getGroup() && $storeModel->getGroup()->getStoresCount() > 1) {
80-
$form->getElement('store_group_id')->setDisabled(true);
81-
82-
$fieldset->addField(
83-
'store_hidden_group_id',
84-
'hidden',
85-
['name' => 'store[group_id]', 'no_span' => true, 'value' => $storeModel->getGroupId()]
86-
);
87-
} else {
88-
$fieldset->addField(
89-
'store_original_group_id',
90-
'hidden',
91-
[
92-
'name' => 'store[original_group_id]',
93-
'no_span' => true,
94-
'value' => $storeModel->getGroupId()
95-
]
96-
);
97-
}
98-
}
77+
$fieldset = $this->prepareGroupIdField($form, $storeModel, $fieldset);
9978
}
10079

10180
$fieldset->addField(
@@ -131,6 +110,7 @@ protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
131110
'options' => [0 => __('Disabled'), 1 => __('Enabled')],
132111
'required' => true,
133112
'disabled' => $storeModel->isReadOnly()
113+
|| ($storeModel->getId() && $storeModel->isDefault() && $storeModel->isActive())
134114
]
135115
);
136116

@@ -185,4 +165,41 @@ protected function _getStoreGroups()
185165
}
186166
return $groups;
187167
}
168+
169+
/**
170+
* Prepare group id field in the fieldset
171+
*
172+
* @param \Magento\Framework\Data\Form $form
173+
* @param \Magento\Store\Model\Store $storeModel
174+
* @param \Magento\Framework\Data\Form\Element\Fieldset $fieldset
175+
* @return \Magento\Framework\Data\Form\Element\Fieldset
176+
*/
177+
private function prepareGroupIdField(
178+
\Magento\Framework\Data\Form $form,
179+
\Magento\Store\Model\Store $storeModel,
180+
\Magento\Framework\Data\Form\Element\Fieldset $fieldset
181+
) {
182+
if ($storeModel->getId() && $storeModel->getGroup()->getDefaultStoreId() == $storeModel->getId()) {
183+
if ($storeModel->getGroup() && $storeModel->getGroup()->getStoresCount() > 1) {
184+
$form->getElement('store_group_id')->setDisabled(true);
185+
186+
$fieldset->addField(
187+
'store_hidden_group_id',
188+
'hidden',
189+
['name' => 'store[group_id]', 'no_span' => true, 'value' => $storeModel->getGroupId()]
190+
);
191+
} else {
192+
$fieldset->addField(
193+
'store_original_group_id',
194+
'hidden',
195+
[
196+
'name' => 'store[original_group_id]',
197+
'no_span' => true,
198+
'value' => $storeModel->getGroupId()
199+
]
200+
);
201+
}
202+
}
203+
return $fieldset;
204+
}
188205
}

app/code/Magento/Backend/Controller/Adminhtml/System/Store/Save.php

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function execute()
4242

4343
case 'group':
4444
$postData['group']['name'] = $this->filterManager->removeTags($postData['group']['name']);
45+
/** @var \Magento\Store\Model\Group $groupModel */
4546
$groupModel = $this->_objectManager->create('Magento\Store\Model\Group');
4647
if ($postData['group']['group_id']) {
4748
$groupModel->load($postData['group']['group_id']);
@@ -50,16 +51,19 @@ public function execute()
5051
if ($postData['group']['group_id'] == '') {
5152
$groupModel->setId(null);
5253
}
53-
54+
if (!$this->isSelectedDefaultStoreActive($postData, $groupModel)) {
55+
throw new \Magento\Framework\Exception\LocalizedException(
56+
__('An inactive store view cannot be saved as default store view')
57+
);
58+
}
5459
$groupModel->save();
55-
5660
$this->_eventManager->dispatch('store_group_save', ['group' => $groupModel]);
57-
5861
$this->messageManager->addSuccess(__('You saved the store.'));
5962
break;
6063

6164
case 'store':
6265
$eventName = 'store_edit';
66+
/** @var \Magento\Store\Model\Store $storeModel */
6367
$storeModel = $this->_objectManager->create('Magento\Store\Model\Store');
6468
$postData['store']['name'] = $this->filterManager->removeTags($postData['store']['name']);
6569
if ($postData['store']['store_id']) {
@@ -76,12 +80,14 @@ public function execute()
7680
$storeModel->getGroupId()
7781
);
7882
$storeModel->setWebsiteId($groupModel->getWebsiteId());
83+
if (!$storeModel->isActive() && $storeModel->isDefault()) {
84+
throw new \Magento\Framework\Exception\LocalizedException(
85+
__('The default store cannot be disabled')
86+
);
87+
}
7988
$storeModel->save();
80-
8189
$this->_objectManager->get('Magento\Store\Model\StoreManager')->reinitStores();
82-
8390
$this->_eventManager->dispatch($eventName, ['store' => $storeModel]);
84-
8591
$this->messageManager->addSuccess(__('You saved the store view.'));
8692
break;
8793
default:
@@ -106,4 +112,24 @@ public function execute()
106112
$redirectResult->setPath('adminhtml/*/');
107113
return $redirectResult;
108114
}
115+
116+
/**
117+
* Verify if selected default store is active
118+
*
119+
* @param array $postData
120+
* @param \Magento\Store\Model\Group $groupModel
121+
* @return bool
122+
*/
123+
private function isSelectedDefaultStoreActive(array $postData, \Magento\Store\Model\Group $groupModel)
124+
{
125+
if (!empty($postData['group']['default_store_id'])) {
126+
$defaultStoreId = $postData['group']['default_store_id'];
127+
if (!empty($groupModel->getStores()[$defaultStoreId]) &&
128+
!$groupModel->getStores()[$defaultStoreId]->isActive()
129+
) {
130+
return false;
131+
}
132+
}
133+
return true;
134+
}
109135
}

app/code/Magento/Catalog/Controller/Category/View.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ public function execute()
192192
if ($layoutUpdates && is_array($layoutUpdates)) {
193193
foreach ($layoutUpdates as $layoutUpdate) {
194194
$page->addUpdate($layoutUpdate);
195+
$page->addPageLayoutHandles(['layout_update' => md5($layoutUpdate)]);
195196
}
196197
}
197198

app/code/Magento/Catalog/Test/Unit/Controller/Category/ViewTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,12 @@ protected function setUp()
125125
$this->pageConfig->expects($this->any())->method('addBodyClass')->will($this->returnSelf());
126126

127127
$this->page = $this->getMockBuilder('Magento\Framework\View\Page')
128-
->setMethods(['getConfig', 'initLayout', 'addPageLayoutHandles', 'getLayout'])
128+
->setMethods(['getConfig', 'initLayout', 'addPageLayoutHandles', 'getLayout', 'addUpdate'])
129129
->disableOriginalConstructor()->getMock();
130130
$this->page->expects($this->any())->method('getConfig')->will($this->returnValue($this->pageConfig));
131131
$this->page->expects($this->any())->method('addPageLayoutHandles')->will($this->returnSelf());
132132
$this->page->expects($this->any())->method('getLayout')->will($this->returnValue($this->layout));
133+
$this->page->expects($this->any())->method('addUpdate')->willReturnSelf();
133134

134135
$this->view = $this->getMock('Magento\Framework\App\ViewInterface');
135136
$this->view->expects($this->any())->method('getLayout')->will($this->returnValue($this->layout));
@@ -192,8 +193,15 @@ public function testApplyCustomLayoutUpdate()
192193

193194
$this->categoryHelper->expects($this->any())->method('canShow')->will($this->returnValue(true));
194195

195-
$settings = $this->getMock('Magento\Framework\DataObject', ['getPageLayout'], [], '', false);
196+
$settings = $this->getMock(
197+
'Magento\Framework\DataObject',
198+
['getPageLayout', 'getLayoutUpdates'],
199+
[],
200+
'',
201+
false
202+
);
196203
$settings->expects($this->atLeastOnce())->method('getPageLayout')->will($this->returnValue($pageLayout));
204+
$settings->expects($this->once())->method('getLayoutUpdates')->willReturn(['update1', 'update2']);
197205

198206
$this->catalogDesign->expects($this->any())->method('getDesignSettings')->will($this->returnValue($settings));
199207

app/code/Magento/Catalog/etc/adminhtml/di.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@
112112
<item name="class" xsi:type="string">Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Categories</item>
113113
<item name="sortOrder" xsi:type="number">60</item>
114114
</item>
115-
<item name="schedule-design-update" xsi:type="array">
115+
<item name="custom-options" xsi:type="array">
116116
<item name="class" xsi:type="string">Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\CustomOptions</item>
117117
<item name="sortOrder" xsi:type="number">70</item>
118118
</item>
119-
<item name="custom-options" xsi:type="array">
119+
<item name="schedule-design-update" xsi:type="array">
120120
<item name="class" xsi:type="string">Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\ScheduleDesignUpdate</item>
121121
<item name="sortOrder" xsi:type="number">80</item>
122122
</item>

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/options.phtml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
// @codingStandardsIgnoreFile
88

99
/** @var $block \Magento\Eav\Block\Adminhtml\Attribute\Edit\Options\Options */
10+
11+
$stores = $block->getStoresSortedBySortOrder();
1012
?>
1113
<fieldset class="fieldset">
1214
<legend class="legend"><span><?php /* @escapeNotVerified */ echo __('Manage Options (Values of Your Attribute)') ?></span></legend>
@@ -15,14 +17,14 @@
1517
<thead>
1618
<tr id="attribute-options-table">
1719
<th class="col-draggable"></th>
18-
<th class="col-default control-table-actions-th"><?php /* @escapeNotVerified */ echo __('Is Default') ?></th>
20+
<th class="col-default control-table-actions-th"><span><?php /* @escapeNotVerified */ echo __('Is Default') ?></span></th>
1921
<?php
20-
$storelist = $block->getStores();
21-
foreach ($storelist as $_store):
22-
?>
23-
<th><?php /* @escapeNotVerified */ echo __($_store->getName()) ?></th>
22+
foreach ($stores as $_store): ?>
23+
<th<?php if ($_store->getId() == \Magento\Store\Model\Store::DEFAULT_STORE_ID): ?> class="_required"<?php endif; ?>>
24+
<span><?php /* @escapeNotVerified */ echo __($_store->getName()) ?></span>
25+
</th>
2426
<?php endforeach;
25-
$storetotal = count($storelist) + 3;
27+
$storetotal = count($stores) + 3;
2628
?>
2729
<th class="col-delete">&nbsp;</th>
2830
</tr>
@@ -59,7 +61,7 @@
5961
<td class="col-default control-table-actions-cell">
6062
<input class="input-radio" type="<%- data.intype %>" name="default[]" value="<%- data.id %>" <%- data.checked %><?php if ($block->getReadOnly()):?>disabled="disabled"<?php endif;?>/>
6163
</td>
62-
<?php foreach ($block->getStores() as $_store): ?>
64+
<?php foreach ($stores as $_store): ?>
6365
<td class="col-<%- data.id %>"><input name="option[value][<%- data.id %>][<?php /* @escapeNotVerified */ echo $_store->getId() ?>]" value="<%- data.store<?php /* @escapeNotVerified */ echo $_store->getId() ?> %>" class="input-text<?php if ($_store->getId() == \Magento\Store\Model\Store::DEFAULT_STORE_ID): ?> required-option<?php endif; ?>" type="text" <?php if ($block->getReadOnly() || $block->canManageOptionDefaultOnly()):?> disabled="disabled"<?php endif;?>/></td>
6466
<?php endforeach; ?>
6567
<td id="delete_button_container_<%- data.id %>" class="col-delete">

app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tab/Conditions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ protected function addTabToForm($model, $fieldsetId = 'conditions_fieldset', $fo
187187
private function setConditionFormName(\Magento\Rule\Model\Condition\AbstractCondition $conditions, $formName)
188188
{
189189
$conditions->setFormName($formName);
190+
$conditions->setJsFormObject($formName);
190191
if ($conditions->getConditions() && is_array($conditions->getConditions())) {
191192
foreach ($conditions->getConditions() as $condition) {
192193
$this->setConditionFormName($condition, $formName);

app/code/Magento/CatalogSearch/view/frontend/templates/advanced/form.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<?php $_code = $_attribute->getAttributeCode() ?>
2323
<div class="field <?php /* @escapeNotVerified */ echo $_code ?>">
2424
<label class="label" for="<?php /* @escapeNotVerified */ echo $_code ?>">
25-
<span><?php echo $block->escapeHtml($block->getAttributeLabel($_attribute)) ?></span>
25+
<span><?php echo $block->escapeHtml(__($block->getAttributeLabel($_attribute))) ?></span>
2626
</label>
2727
<div class="control">
2828
<?php switch ($block->getAttributeInputType($_attribute)):

0 commit comments

Comments
 (0)