Skip to content

Commit

Permalink
Merge pull request #1052 from magento-troll/troll_bugfix_kanban
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rganin authored Apr 24, 2017
2 parents bbe3ee0 + 29133fb commit 32e09b5
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 24 deletions.
21 changes: 13 additions & 8 deletions app/code/Magento/Backend/Block/System/Store/Edit/Form/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
$storeModel->setData($postData['store']);
}
$fieldset = $form->addFieldset('store_fieldset', ['legend' => __('Store View Information')]);

$storeAction = $this->_coreRegistry->registry('store_action');
if ($storeAction == 'edit' || $storeAction == 'add') {
$fieldset->addField(
Expand All @@ -76,7 +75,6 @@ protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
);
$fieldset = $this->prepareGroupIdField($form, $storeModel, $fieldset);
}

$fieldset->addField(
'store_name',
'text',
Expand All @@ -99,7 +97,8 @@ protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
'disabled' => $storeModel->isReadOnly()
]
);

$isDisabledStatusField = $storeModel->isReadOnly()
|| ($storeModel->getId() && $storeModel->isDefault() && $storeModel->isActive());
$fieldset->addField(
'store_is_active',
'select',
Expand All @@ -109,11 +108,19 @@ protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
'value' => $storeModel->isActive(),
'options' => [0 => __('Disabled'), 1 => __('Enabled')],
'required' => true,
'disabled' => $storeModel->isReadOnly()
|| ($storeModel->getId() && $storeModel->isDefault() && $storeModel->isActive())
'disabled' => $isDisabledStatusField
]
);

if ($isDisabledStatusField) {
$fieldset->addField(
'store_is_active_hidden',
'hidden',
[
'name' => 'store[is_active]',
'value' => $storeModel->isActive(),
]
);
}
$fieldset->addField(
'store_sort_order',
'text',
Expand All @@ -125,13 +132,11 @@ protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
'disabled' => $storeModel->isReadOnly()
]
);

$fieldset->addField(
'store_is_default',
'hidden',
['name' => 'store[is_default]', 'no_span' => true, 'value' => $storeModel->getIsDefault()]
);

$fieldset->addField(
'store_store_id',
'hidden',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ private function setMessageToResponse($response, $messages)
private function checkUniqueOption(DataObject $response, array $options = null)
{
if (is_array($options)
&& isset($options['value'])
&& isset($options['delete'])
&& !empty($options['value'])
&& !empty($options['delete'])
&& !$this->isUniqueAdminValues($options['value'], $options['delete'])
) {
$this->setMessageToResponse($response, [__("The value of Admin must be unique.")]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,16 @@ public function testUniqueValidation(array $options, $isError)
public function provideUniqueData()
{
return [
// valid options
[
'no values' => [
[
'delete' => [
"option_0" => "",
"option_1" => "",
"option_2" => "",
]
], false
],
'valid options' => [
[
'value' => [
"option_0" => [1, 0],
Expand All @@ -213,8 +221,7 @@ public function provideUniqueData()
]
], false
],
//with duplicate
[
'duplicate options' => [
[
'value' => [
"option_0" => [1, 0],
Expand All @@ -228,8 +235,7 @@ public function provideUniqueData()
]
], true
],
//with duplicate but deleted
[
'duplicate and deleted' => [
[
'value' => [
"option_0" => [1, 0],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Magento\Backend\Test\Page\Adminhtml\StoreIndex;
use Magento\Store\Test\Fixture\Store;
use Magento\Mtf\TestCase\Injectable;
use Magento\Store\Test\TestStep\RestoreDefaultStoreViewStep;

/**
* Test Creation for UpdateStoreEntity (Store Management)
Expand Down Expand Up @@ -50,17 +51,36 @@ class UpdateStoreEntityTest extends Injectable
*/
protected $editStore;

/**
* Restore Default Store View step.
*
* @var RestoreDefaultStoreViewStep
*/
private $restoreDefaultStoreViewStep;

/**
* Initial store fixture.
*
* @var Store
*/
private $storeInitial;

/**
* Preparing pages for test
*
* @param StoreIndex $storeIndex
* @param EditStore $editStore
* @param RestoreDefaultStoreViewStep $restoreDefaultStoreViewStep
* @return void
*/
public function __inject(StoreIndex $storeIndex, EditStore $editStore)
{
public function __inject(
StoreIndex $storeIndex,
EditStore $editStore,
RestoreDefaultStoreViewStep $restoreDefaultStoreViewStep
) {
$this->storeIndex = $storeIndex;
$this->editStore = $editStore;
$this->restoreDefaultStoreViewStep = $restoreDefaultStoreViewStep;
}

/**
Expand All @@ -73,6 +93,7 @@ public function __inject(StoreIndex $storeIndex, EditStore $editStore)
public function test(Store $storeInitial, Store $store)
{
// Preconditions:
$this->storeInitial = $storeInitial;
$storeInitial->persist();

// Steps:
Expand All @@ -81,4 +102,14 @@ public function test(Store $storeInitial, Store $store)
$this->editStore->getStoreForm()->fill($store);
$this->editStore->getFormPageActions()->save();
}

/**
* {@inheritdoc}
*/
protected function tearDown()
{
if ($this->storeInitial->getCode() == 'default') {
$this->restoreDefaultStoreViewStep->run();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,11 @@
<constraint name="Magento\Store\Test\Constraint\AssertStoreBackend" />
<constraint name="Magento\Store\Test\Constraint\AssertStoreFrontend" />
</variation>
<variation name="UpdateStoreEntityTestVariation2">
<data name="tag" xsi:type="string">severity:S1</data>
<data name="storeInitial/dataset" xsi:type="string">default</data>
<data name="store/data/name" xsi:type="string">storename_updated%isolation%</data>
<constraint name="Magento\Store\Test\Constraint\AssertStoreSuccessSaveMessage" />
</variation>
</testCase>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Store\Test\TestStep;

use Magento\Mtf\TestStep\TestStepInterface;
use Magento\Store\Test\Fixture\Store;

/**
* Restore DefaultStore view.
*/
class RestoreDefaultStoreViewStep implements TestStepInterface
{
/**
* Fixture of Store View.
*
* @var Store
*/
private $storeView;

/**
* @param Store $storeView
*/
public function __construct(Store $storeView)
{
$this->storeView = $storeView;
}

/**
* Restore Default Store View.
*
* @return void
*/
public function run()
{
$this->storeView->persist();
}
}
10 changes: 5 additions & 5 deletions lib/internal/Magento/Framework/DB/Query/BatchRangeIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class BatchRangeIterator implements BatchIteratorInterface
/**
* @var int
*/
private $currentBatch = 0;
private $currentOffset = 0;

/**
* @var int
Expand Down Expand Up @@ -107,7 +107,7 @@ public function __construct(
public function current()
{
if (null === $this->currentSelect) {
$this->isValid = ($this->currentBatch + $this->batchSize) < $this->totalItemCount;
$this->isValid = ($this->currentOffset + $this->batchSize) < $this->totalItemCount;
$this->currentSelect = $this->initSelectObject();
}
return $this->currentSelect;
Expand Down Expand Up @@ -138,7 +138,7 @@ public function next()
if (null === $this->currentSelect) {
$this->current();
}
$this->isValid = ($this->batchSize + $this->currentBatch) < $this->totalItemCount;
$this->isValid = ($this->batchSize + $this->currentOffset) < $this->totalItemCount;
$select = $this->initSelectObject();
if ($this->isValid) {
$this->iteration++;
Expand Down Expand Up @@ -201,8 +201,8 @@ private function initSelectObject()
* Reset sort order section from origin select object
*/
$object->order($this->correlationName . '.' . $this->rangeField . ' ' . \Magento\Framework\DB\Select::SQL_ASC);
$object->limit($this->currentBatch, $this->batchSize);
$this->currentBatch += $this->batchSize;
$object->limit($this->batchSize, $this->currentOffset);
$this->currentOffset += $this->batchSize;

return $object;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected function setUp()
*/
public function testCurrent()
{
$this->selectMock->expects($this->once())->method('limit')->with($this->currentBatch, $this->batchSize);
$this->selectMock->expects($this->once())->method('limit')->with($this->batchSize, $this->currentBatch);
$this->selectMock->expects($this->once())->method('order')->with('correlationName.rangeField' . ' ASC');
$this->assertEquals($this->selectMock, $this->model->current());
$this->assertEquals(0, $this->model->key());
Expand Down

0 comments on commit 32e09b5

Please sign in to comment.