AD0-E725 practice question 2 of 10

A Developer is tasked with creating a new index. The custom indexer is not automatically updating the product data. How should the Developer solve this issue?

Full set: 50 questions
Answer options
A: Use an event observer to monitor data changes.
B: Use the mview to allow tracking database changes. Correct answer
C: Implement custom database triggers.
Correct Answer:
B. Use the mview to allow tracking database changes.
Explanation

The Magento framework uses the Materialized View (MView) mechanism to track database changes for indexers. By defining subscriptions to specific database tables and columns in the mview.xml configuration file for the custom indexer, the developer instructs Magento to automatically create database triggers. These triggers monitor the source tables (e.g., product tables) for any changes (INSERT, UPDATE, DELETE). When a change occurs, the trigger records the primary key of the affected entity into a corresponding changelog table. This allows the indexer, when running in "Update on Save" mode, to efficiently process only the changed data, ensuring the index is updated automatically.

Why Incorrect

A. Use an event observer to monitor data changes. While observers react to events, they are not the standard or most efficient mechanism for tracking database changes for indexing, which the MView system is specifically designed for.
C. Implement custom database triggers. Manually creating database triggers is incorrect because it bypasses the Magento framework. The MView system is designed to manage the lifecycle of these triggers declaratively via XML configuration.

References

1. Adobe Commerce Developer Documentation

"Configure a custom indexer": This document explicitly states the role of mview.xml: "The mview.xml file is used to track database changes for a specific entity and to run the handler to update the index." It details how to define views

subscriptions

and tables to be monitored.

Source: Adobe Commerce Developer Documentation > Indexing > Custom indexers > Configure a custom indexer.

2. Adobe Commerce Developer Documentation

"How indexing works": This guide explains the core indexing mechanism

stating

"In Update on Save mode

database triggers are used to update the index tables immediately after the data is changed." It clarifies that this process is managed by the MView subscriptions.

Source: Adobe Commerce Developer Documentation > Indexing > How indexing works > Indexing mechanism.

Scroll to Top