Skip to content

Always set customer_grid to realtime #11

Description

@peterjaap

TIL:

Customer Grid can only be reindexed using Update on Save. This index does not support Update by Schedule.

Source; https://experienceleague.adobe.com/en/docs/commerce-admin/systems/tools/index-management#change-the-index-mode

Maybe we can add it to this extension so that customer_grid is always set to realtime when we run indexer:lock-all?

I've now used this script to move it (we had to do this for 20+ projects);

<?php

use Symfony\Component\VarExporter\VarExporter;

require 'vendor/autoload.php';

$filePath = 'app/etc/config.php';
$config = include $filePath;

// Remove 'customer_grid' from 'indexers/schedule' if it exists
if (isset($config['indexers']['schedule'])) {
    $config['indexers']['schedule'] = array_filter(
        $config['indexers']['schedule'],
        fn($indexer) => $indexer !== 'customer_grid'
    );

    // Re-index to maintain array structure
    $config['indexers']['schedule'] = array_values($config['indexers']['schedule']);
}

// Ensure 'indexers/realtime' exists and add 'customer_grid' if not present
$config['indexers']['realtime'] ??= [];
if (!in_array('customer_grid', $config['indexers']['realtime'], true)) {
    $config['indexers']['realtime'][] = 'customer_grid';
}

// Use Symfony VarExporter to export the array
$output = "<?php\n\nreturn " . VarExporter::export($config) . ";\n";

// Write the exported configuration back to the file
file_put_contents($filePath, $output);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions