Skip to content

Commit bfe2f14

Browse files
author
Sergey Semenov
committed
Merge remote-tracking branch 'mainline/develop' into BUGS
2 parents 49b9f29 + c3199e7 commit bfe2f14

File tree

59 files changed

+573
-226
lines changed

Some content is hidden

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

59 files changed

+573
-226
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/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/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)):

app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ define(
7979
isAddressDetailsVisible: quote.billingAddress() != null,
8080
isAddressFormVisible: !customer.isLoggedIn() || addressOptions.length == 1,
8181
isAddressSameAsShipping: false,
82-
saveInAddressBook: true
82+
saveInAddressBook: 1
8383
});
8484

8585
quote.billingAddress.subscribe(function (newAddress) {
@@ -95,7 +95,7 @@ define(
9595
if (newAddress != null && newAddress.saveInAddressBook !== undefined) {
9696
this.saveInAddressBook(newAddress.saveInAddressBook);
9797
} else {
98-
this.saveInAddressBook(true);
98+
this.saveInAddressBook(1);
9999
}
100100
this.isAddressDetailsVisible(true);
101101
}, this);
@@ -157,7 +157,7 @@ define(
157157
newBillingAddress;
158158

159159
if (customer.isLoggedIn() && !this.customerHasAddresses) {
160-
this.saveInAddressBook(true);
160+
this.saveInAddressBook(1);
161161
}
162162
addressData.save_in_address_book = this.saveInAddressBook();
163163
newBillingAddress = createBillingAddress(addressData);

app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ define(
6767
isFormPopUpVisible: formPopUpState.isVisible,
6868
isFormInline: addressList().length == 0,
6969
isNewAddressAdded: ko.observable(false),
70-
saveInAddressBook: true,
70+
saveInAddressBook: 1,
7171
quoteIsVirtual: quote.isVirtual(),
7272

7373
/**
@@ -296,7 +296,7 @@ define(
296296
}
297297

298298
if (customer.isLoggedIn()) {
299-
shippingAddress.save_in_address_book = true;
299+
shippingAddress.save_in_address_book = 1;
300300
}
301301
selectShippingAddress(shippingAddress);
302302
}

app/code/Magento/Cms/Setup/InstallData.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
336336
$content = preg_replace('/<li class="last">/ims', '<li>', $content);
337337
$replacment = '<li class="last privacy">' .
338338
"<a href=\"{{store direct_url=\"privacy-policy-cookie-restriction-mode\"}}\">" .
339-
"Privacy and Cookie Policy</a></li>\r\n</ul>";
339+
__('Privacy and Cookie Policy') . "</a></li>\r\n</ul>";
340340
$content = preg_replace('/<\\/ul>/ims', $replacment, $content);
341341
$footerLinksBlock->setContent($content)->save();
342342
}

0 commit comments

Comments
 (0)