Skip to content

Commit 32e09b5

Browse files
authored
Merge pull request #1052 from magento-troll/troll_bugfix_kanban
MAGETWO-60746 [GITHUB] Edit default store view will stop saying that Default store cannot be disabled #7349 MAGETWO-63736 503 error when trying to make tax_class_id attribute Not Searchable MAGETWO-63601 [GitHub] Running indexer:reindex catalog_category_product fails due to limit 500 #8018
2 parents bbe3ee0 + 29133fb commit 32e09b5

File tree

8 files changed

+113
-24
lines changed

8 files changed

+113
-24
lines changed

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
5959
$storeModel->setData($postData['store']);
6060
}
6161
$fieldset = $form->addFieldset('store_fieldset', ['legend' => __('Store View Information')]);
62-
6362
$storeAction = $this->_coreRegistry->registry('store_action');
6463
if ($storeAction == 'edit' || $storeAction == 'add') {
6564
$fieldset->addField(
@@ -76,7 +75,6 @@ protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
7675
);
7776
$fieldset = $this->prepareGroupIdField($form, $storeModel, $fieldset);
7877
}
79-
8078
$fieldset->addField(
8179
'store_name',
8280
'text',
@@ -99,7 +97,8 @@ protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
9997
'disabled' => $storeModel->isReadOnly()
10098
]
10199
);
102-
100+
$isDisabledStatusField = $storeModel->isReadOnly()
101+
|| ($storeModel->getId() && $storeModel->isDefault() && $storeModel->isActive());
103102
$fieldset->addField(
104103
'store_is_active',
105104
'select',
@@ -109,11 +108,19 @@ protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
109108
'value' => $storeModel->isActive(),
110109
'options' => [0 => __('Disabled'), 1 => __('Enabled')],
111110
'required' => true,
112-
'disabled' => $storeModel->isReadOnly()
113-
|| ($storeModel->getId() && $storeModel->isDefault() && $storeModel->isActive())
111+
'disabled' => $isDisabledStatusField
114112
]
115113
);
116-
114+
if ($isDisabledStatusField) {
115+
$fieldset->addField(
116+
'store_is_active_hidden',
117+
'hidden',
118+
[
119+
'name' => 'store[is_active]',
120+
'value' => $storeModel->isActive(),
121+
]
122+
);
123+
}
117124
$fieldset->addField(
118125
'store_sort_order',
119126
'text',
@@ -125,13 +132,11 @@ protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
125132
'disabled' => $storeModel->isReadOnly()
126133
]
127134
);
128-
129135
$fieldset->addField(
130136
'store_is_default',
131137
'hidden',
132138
['name' => 'store[is_default]', 'no_span' => true, 'value' => $storeModel->getIsDefault()]
133139
);
134-
135140
$fieldset->addField(
136141
'store_store_id',
137142
'hidden',

app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ private function setMessageToResponse($response, $messages)
155155
private function checkUniqueOption(DataObject $response, array $options = null)
156156
{
157157
if (is_array($options)
158-
&& isset($options['value'])
159-
&& isset($options['delete'])
158+
&& !empty($options['value'])
159+
&& !empty($options['delete'])
160160
&& !$this->isUniqueAdminValues($options['value'], $options['delete'])
161161
) {
162162
$this->setMessageToResponse($response, [__("The value of Admin must be unique.")]);

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/ValidateTest.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,16 @@ public function testUniqueValidation(array $options, $isError)
198198
public function provideUniqueData()
199199
{
200200
return [
201-
// valid options
202-
[
201+
'no values' => [
202+
[
203+
'delete' => [
204+
"option_0" => "",
205+
"option_1" => "",
206+
"option_2" => "",
207+
]
208+
], false
209+
],
210+
'valid options' => [
203211
[
204212
'value' => [
205213
"option_0" => [1, 0],
@@ -213,8 +221,7 @@ public function provideUniqueData()
213221
]
214222
], false
215223
],
216-
//with duplicate
217-
[
224+
'duplicate options' => [
218225
[
219226
'value' => [
220227
"option_0" => [1, 0],
@@ -228,8 +235,7 @@ public function provideUniqueData()
228235
]
229236
], true
230237
],
231-
//with duplicate but deleted
232-
[
238+
'duplicate and deleted' => [
233239
[
234240
'value' => [
235241
"option_0" => [1, 0],

dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest.php

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Backend\Test\Page\Adminhtml\StoreIndex;
1111
use Magento\Store\Test\Fixture\Store;
1212
use Magento\Mtf\TestCase\Injectable;
13+
use Magento\Store\Test\TestStep\RestoreDefaultStoreViewStep;
1314

1415
/**
1516
* Test Creation for UpdateStoreEntity (Store Management)
@@ -50,17 +51,36 @@ class UpdateStoreEntityTest extends Injectable
5051
*/
5152
protected $editStore;
5253

54+
/**
55+
* Restore Default Store View step.
56+
*
57+
* @var RestoreDefaultStoreViewStep
58+
*/
59+
private $restoreDefaultStoreViewStep;
60+
61+
/**
62+
* Initial store fixture.
63+
*
64+
* @var Store
65+
*/
66+
private $storeInitial;
67+
5368
/**
5469
* Preparing pages for test
5570
*
5671
* @param StoreIndex $storeIndex
5772
* @param EditStore $editStore
73+
* @param RestoreDefaultStoreViewStep $restoreDefaultStoreViewStep
5874
* @return void
5975
*/
60-
public function __inject(StoreIndex $storeIndex, EditStore $editStore)
61-
{
76+
public function __inject(
77+
StoreIndex $storeIndex,
78+
EditStore $editStore,
79+
RestoreDefaultStoreViewStep $restoreDefaultStoreViewStep
80+
) {
6281
$this->storeIndex = $storeIndex;
6382
$this->editStore = $editStore;
83+
$this->restoreDefaultStoreViewStep = $restoreDefaultStoreViewStep;
6484
}
6585

6686
/**
@@ -73,6 +93,7 @@ public function __inject(StoreIndex $storeIndex, EditStore $editStore)
7393
public function test(Store $storeInitial, Store $store)
7494
{
7595
// Preconditions:
96+
$this->storeInitial = $storeInitial;
7697
$storeInitial->persist();
7798

7899
// Steps:
@@ -81,4 +102,14 @@ public function test(Store $storeInitial, Store $store)
81102
$this->editStore->getStoreForm()->fill($store);
82103
$this->editStore->getFormPageActions()->save();
83104
}
105+
106+
/**
107+
* {@inheritdoc}
108+
*/
109+
protected function tearDown()
110+
{
111+
if ($this->storeInitial->getCode() == 'default') {
112+
$this->restoreDefaultStoreViewStep->run();
113+
}
114+
}
84115
}

dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,11 @@
2020
<constraint name="Magento\Store\Test\Constraint\AssertStoreBackend" />
2121
<constraint name="Magento\Store\Test\Constraint\AssertStoreFrontend" />
2222
</variation>
23+
<variation name="UpdateStoreEntityTestVariation2">
24+
<data name="tag" xsi:type="string">severity:S1</data>
25+
<data name="storeInitial/dataset" xsi:type="string">default</data>
26+
<data name="store/data/name" xsi:type="string">storename_updated%isolation%</data>
27+
<constraint name="Magento\Store\Test\Constraint\AssertStoreSuccessSaveMessage" />
28+
</variation>
2329
</testCase>
2430
</config>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Store\Test\TestStep;
8+
9+
use Magento\Mtf\TestStep\TestStepInterface;
10+
use Magento\Store\Test\Fixture\Store;
11+
12+
/**
13+
* Restore DefaultStore view.
14+
*/
15+
class RestoreDefaultStoreViewStep implements TestStepInterface
16+
{
17+
/**
18+
* Fixture of Store View.
19+
*
20+
* @var Store
21+
*/
22+
private $storeView;
23+
24+
/**
25+
* @param Store $storeView
26+
*/
27+
public function __construct(Store $storeView)
28+
{
29+
$this->storeView = $storeView;
30+
}
31+
32+
/**
33+
* Restore Default Store View.
34+
*
35+
* @return void
36+
*/
37+
public function run()
38+
{
39+
$this->storeView->persist();
40+
}
41+
}

lib/internal/Magento/Framework/DB/Query/BatchRangeIterator.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class BatchRangeIterator implements BatchIteratorInterface
4646
/**
4747
* @var int
4848
*/
49-
private $currentBatch = 0;
49+
private $currentOffset = 0;
5050

5151
/**
5252
* @var int
@@ -107,7 +107,7 @@ public function __construct(
107107
public function current()
108108
{
109109
if (null === $this->currentSelect) {
110-
$this->isValid = ($this->currentBatch + $this->batchSize) < $this->totalItemCount;
110+
$this->isValid = ($this->currentOffset + $this->batchSize) < $this->totalItemCount;
111111
$this->currentSelect = $this->initSelectObject();
112112
}
113113
return $this->currentSelect;
@@ -138,7 +138,7 @@ public function next()
138138
if (null === $this->currentSelect) {
139139
$this->current();
140140
}
141-
$this->isValid = ($this->batchSize + $this->currentBatch) < $this->totalItemCount;
141+
$this->isValid = ($this->batchSize + $this->currentOffset) < $this->totalItemCount;
142142
$select = $this->initSelectObject();
143143
if ($this->isValid) {
144144
$this->iteration++;
@@ -201,8 +201,8 @@ private function initSelectObject()
201201
* Reset sort order section from origin select object
202202
*/
203203
$object->order($this->correlationName . '.' . $this->rangeField . ' ' . \Magento\Framework\DB\Select::SQL_ASC);
204-
$object->limit($this->currentBatch, $this->batchSize);
205-
$this->currentBatch += $this->batchSize;
204+
$object->limit($this->batchSize, $this->currentOffset);
205+
$this->currentOffset += $this->batchSize;
206206

207207
return $object;
208208
}

lib/internal/Magento/Framework/Test/Unit/DB/Query/BatchRangeIteratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ protected function setUp()
9494
*/
9595
public function testCurrent()
9696
{
97-
$this->selectMock->expects($this->once())->method('limit')->with($this->currentBatch, $this->batchSize);
97+
$this->selectMock->expects($this->once())->method('limit')->with($this->batchSize, $this->currentBatch);
9898
$this->selectMock->expects($this->once())->method('order')->with('correlationName.rangeField' . ' ASC');
9999
$this->assertEquals($this->selectMock, $this->model->current());
100100
$this->assertEquals(0, $this->model->key());

0 commit comments

Comments
 (0)