Skip to content

Commit 4483d42

Browse files
committed
AC-13810: Customer Grid indexer does not work properly in Update by Schedule mode
1 parent e0431ab commit 4483d42

File tree

6 files changed

+66
-12
lines changed

6 files changed

+66
-12
lines changed

app/code/Magento/Customer/Model/Address.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2011 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento\Customer\Model;
77

@@ -371,7 +371,9 @@ public function reindex()
371371
{
372372
/** @var \Magento\Framework\Indexer\IndexerInterface $indexer */
373373
$indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
374-
$indexer->reindexRow($this->getCustomerId());
374+
if (!$indexer->isScheduled()) {
375+
$indexer->reindexRow($this->getCustomerId());
376+
}
375377
}
376378

377379
/**

app/code/Magento/Customer/Model/Customer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,9 @@ public function afterDeleteCommit()
11271127
*/
11281128
public function reindex()
11291129
{
1130-
$this->getIndexer()->reindexRow($this->getId());
1130+
if (!$this->getIndexer()->isScheduled()) {
1131+
$this->getIndexer()->reindexRow($this->getId());
1132+
}
11311133
}
11321134

11331135
/**

app/code/Magento/Customer/etc/di.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0"?>
22
<!--
33
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
4+
* Copyright 2013 Adobe
5+
* All Rights Reserved.
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
@@ -593,4 +593,9 @@
593593
type="Magento\Customer\Plugin\AsyncRequestCustomerGroupAuthorization"
594594
/>
595595
</type>
596+
<virtualType name="Magento\Customer\Model\MviewAction" type="\Magento\Framework\Mview\View\BaseAction">
597+
<arguments>
598+
<argument name="indexerId" xsi:type="string">customer_grid</argument>
599+
</arguments>
600+
</virtualType>
596601
</config>

app/code/Magento/Customer/etc/indexer.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?xml version="1.0"?>
22
<!--
33
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
4+
* Copyright 2015 Adobe
5+
* All Rights Reserved.
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="urn:magento:framework:Indexer/etc/indexer.xsd">
10-
<indexer id="customer_grid" view_id="customer_dummy" class="Magento\Framework\Indexer\Action\Entity" primary="customer">
10+
<indexer id="customer_grid" view_id="customer_grid_flat" class="Magento\Framework\Indexer\Action\Entity" primary="customer">
1111
<title translate="true">Customer Grid</title>
1212
<description translate="true">Rebuild Customer grid index</description>
1313

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
4+
* Copyright 2015 Adobe
5+
* All Rights Reserved.
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Mview/etc/mview.xsd">
9-
<view id="customer_dummy" class="Magento\Framework\Indexer\Action\Dummy" group="indexer"/>
9+
<view id="customer_grid_flat" class="Magento\Customer\Model\MviewAction" group="indexer">
10+
<subscriptions>
11+
<table name="customer_entity" entity_column="entity_id" />
12+
<table name="customer_entity_datetime" entity_column="entity_id" />
13+
<table name="customer_entity_decimal" entity_column="entity_id" />
14+
<table name="customer_entity_int" entity_column="entity_id" />
15+
<table name="customer_address_entity" entity_column="parent_id" />
16+
</subscriptions>
17+
</view>
1018
</config>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
namespace Magento\Framework\Mview\View;
7+
8+
use Magento\Framework\Indexer\IndexerRegistry;
9+
10+
/**
11+
* Action the use indexer to reindex items
12+
*/
13+
class BaseAction implements \Magento\Framework\Mview\ActionInterface
14+
{
15+
/**
16+
* @param IndexerRegistry $indexerRegistry
17+
* @param string $indexerId
18+
*/
19+
public function __construct(
20+
private IndexerRegistry $indexerRegistry,
21+
private string $indexerId
22+
) {
23+
}
24+
25+
/**
26+
* Execute materialization on ids entities
27+
*
28+
* @param int[] $ids
29+
* @return void
30+
*/
31+
public function execute($ids)
32+
{
33+
/** @var \Magento\Framework\Indexer\IndexerInterface $indexer */
34+
$indexer = $this->indexerRegistry->get($this->indexerId);
35+
$indexer->reindexList($ids);
36+
}
37+
}

0 commit comments

Comments
 (0)