Skip to content

Commit c649e28

Browse files
committed
Merge remote-tracking branch 'charlie/PR_36422' into comm_voted
2 parents 647b34e + 08db5a1 commit c649e28

File tree

6 files changed

+38
-9
lines changed

6 files changed

+38
-9
lines changed

app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassChangelog.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,28 @@ public function execute()
2424
if (!is_array($indexerIds)) {
2525
$this->messageManager->addErrorMessage(__('Please select indexers.'));
2626
} else {
27+
$updatedIndexersCount = 0;
28+
2729
try {
2830
foreach ($indexerIds as $indexerId) {
2931
/** @var \Magento\Framework\Indexer\IndexerInterface $model */
3032
$model = $this->_objectManager->get(
3133
\Magento\Framework\Indexer\IndexerRegistry::class
3234
)->get($indexerId);
33-
$model->setScheduled(true);
35+
36+
if (!$model->isScheduled()) {
37+
$model->setScheduled(true);
38+
$updatedIndexersCount++;
39+
}
3440
}
35-
$this->messageManager->addSuccess(
36-
__('%1 indexer(s) are in "Update by Schedule" mode.', count($indexerIds))
41+
42+
$this->messageManager->addSuccessMessage(
43+
__(
44+
'%1 indexer(s) have been updated to "Update by Schedule" mode.
45+
%2 skipped because there was nothing to change.',
46+
$updatedIndexersCount,
47+
count($indexerIds) - $updatedIndexersCount
48+
)
3749
);
3850
} catch (\Magento\Framework\Exception\LocalizedException $e) {
3951
$this->messageManager->addErrorMessage($e->getMessage());

app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassOnTheFly.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,28 @@ public function execute()
2424
if (!is_array($indexerIds)) {
2525
$this->messageManager->addErrorMessage(__('Please select indexers.'));
2626
} else {
27+
$updatedIndexersCount = 0;
28+
2729
try {
2830
foreach ($indexerIds as $indexerId) {
2931
/** @var \Magento\Framework\Indexer\IndexerInterface $model */
3032
$model = $this->_objectManager->get(
3133
\Magento\Framework\Indexer\IndexerRegistry::class
3234
)->get($indexerId);
33-
$model->setScheduled(false);
35+
36+
if ($model->isScheduled()) {
37+
$model->setScheduled(false);
38+
$updatedIndexersCount++;
39+
}
3440
}
35-
$this->messageManager->addSuccess(
36-
__('%1 indexer(s) are in "Update on Save" mode.', count($indexerIds))
41+
42+
$this->messageManager->addSuccessMessage(
43+
__(
44+
'%1 indexer(s) have been updated to "Update on Save" mode.
45+
%2 skipped because there was nothing to change.',
46+
$updatedIndexersCount,
47+
count($indexerIds) - $updatedIndexersCount
48+
)
3749
);
3850
} catch (\Magento\Framework\Exception\LocalizedException $e) {
3951
$this->messageManager->addErrorMessage($e->getMessage());

app/code/Magento/Indexer/Test/Mftf/ActionGroup/AdminSwitchAllIndexerToActionModeActionGroup.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
<actionGroup name="AdminSwitchAllIndexerToActionModeActionGroup">
1212
<arguments>
1313
<argument name="action" type="string" defaultValue="Update by Schedule"/>
14+
<!-- <argument name="count" type="string" defaultValue="10"/> -->
1415
</arguments>
1516
<amOnPage url="{{AdminIndexManagementPage.url}}" stepKey="onIndexManagement"/>
1617
<waitForPageLoad stepKey="waitForManagementPage"/>
1718
<selectOption userInput="selectAll" selector="{{AdminIndexManagementSection.selectMassAction}}" stepKey="checkIndexer"/>
1819
<selectOption userInput="{{action}}" selector="{{AdminIndexManagementSection.massActionSelect}}" stepKey="selectAction"/>
20+
<grabValueFrom selector="{{AdminIndexManagementSection.massIndexSelectionCount}}" stepKey="selectCount"/>
1921
<click selector="{{AdminIndexManagementSection.massActionSubmit}}" stepKey="clickSubmit"/>
2022
<waitForPageLoad stepKey="waitForSubmit"/>
21-
<see userInput="indexer(s) are in &quot;{{action}}&quot; mode." stepKey="seeMessage"/>
23+
<see userInput="{$selectCount} indexer(s) have been updated to &quot;{{action}}&quot; mode. 0 skipped because there was nothing to change." stepKey="seeMessage"/>
2224
</actionGroup>
2325
</actionGroups>

app/code/Magento/Indexer/Test/Mftf/ActionGroup/AdminSwitchIndexerToActionModeActionGroup.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
<selectOption userInput="{{action}}" selector="{{AdminIndexManagementSection.massActionSelect}}" stepKey="selectAction"/>
1818
<click selector="{{AdminIndexManagementSection.massActionSubmit}}" stepKey="clickSubmit"/>
1919
<waitForPageLoad stepKey="waitForSubmit"/>
20-
<see selector="{{AdminIndexManagementSection.successMessage}}" userInput="1 indexer(s) are in &quot;{{action}}&quot; mode." stepKey="seeMessage"/>
20+
<see selector="{{AdminIndexManagementSection.successMessage}}" userInput="1 indexer(s) have been updated to &quot;{{action}}&quot; mode. 0 skipped because there was nothing to change." stepKey="seeMessage"/>
2121
</actionGroup>
2222
</actionGroups>

app/code/Magento/Indexer/Test/Mftf/Section/AdminIndexManagementSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
<element name="selectMassAction" type="select" selector="#gridIndexer_massaction-mass-select"/>
2020
<element name="columnScheduleStatus" type="text" selector="//th[contains(@class, 'col-indexer_schedule_status')]"/>
2121
<element name="indexerScheduleStatus" type="text" selector="//tr[contains(.,'{{var1}}')]//td[contains(@class,'col-indexer_schedule_status')]" parameterized="true"/>
22+
<element name="massIndexSelectionCount" type="text" selector="#gridIndexer-total-count"/>
2223
</section>
2324
</sections>

app/code/Magento/Indexer/Test/Unit/Controller/Adminhtml/Indexer/MassOnTheFlyTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class MassOnTheFlyTest extends TestCase
8282
protected $indexReg;
8383

8484
/**
85-
* @return ResponseInterface
85+
* @var ResponseInterface
8686
*/
8787
protected $response;
8888

@@ -223,6 +223,8 @@ public function testExecute($indexerIds, $exception, $expectsExceptionValues)
223223
->willReturn($indexerInterface);
224224

225225
if ($exception !== null) {
226+
$indexerInterface->expects($this->any())
227+
->method('isScheduled')->willReturn(true);
226228
$indexerInterface->expects($this->any())
227229
->method('setScheduled')->with(false)->willThrowException($exception);
228230
} else {

0 commit comments

Comments
 (0)