Skip to content

[Issue] Allow ignored columns for mview to be specified at the subscription level #30243

Closed
@m2-assistant

Description

@m2-assistant

This issue is automatically created based on existing pull request: #29692: Allow ignored columns for mview to be specified at the subscription level


Summary (*)

Magento 2.4-develop
Current configuration options for indexer subscriptions are limited - only allowing a table to be specified, rather than specific columns that we may be interested in.
Likewise \Magento\Framework\Mview\View\Subscription has the argument $ignoredUpdateColumns, which by default only includes updated_at. This argument is used to ignore columns for update triggers globally.

This change adds another argument to \Magento\Framework\Mview\View\Subscription to allow for columns to be ignored for a specific view/table combination (i.e. at the subscription level).

Example use-case:
You may wish to subscribe to the salesrule table for a custom indexer (e.g. view id of "my_custom_view"), but with current functionality, this results in a reindex occurring any time an order is placed which had the rule applied, due to the times_used column being updated.

With the following di.xml entries, we can specifically ignore the times_used column for our indexer view:

<type name="Magento\Framework\Mview\View\Subscription">
    <arguments>
        <argument name="ignoredUpdateColumnsBySubscription" xsi:type="array">
            <item name="my_custom_view" xsi:type="array">
                <item name="salesrule" xsi:type="array">
                    <item name="times_used" xsi:type="string">times_used</item>
                </item>
            </item>
        </argument>
    </arguments>
</type>

Examples (*)

  1. Add di.xml configuration for an existing view - e.g. cataloginventory_stock:
<type name="Magento\Framework\Mview\View\Subscription">
    <arguments>
        <argument name="ignoredUpdateColumnsBySubscription" xsi:type="array">
            <item name="cataloginventory_stock" xsi:type="array">
                <item name="cataloginventory_stock_item" xsi:type="array">
                    <item name="low_stock_date" xsi:type="string">low_stock_date</item>
                </item>
            </item>
        </argument>
    </arguments>
</type>
  1. Set all indexers to update on save (this will remove existing triggers)
  2. Set all indexers to update by schedule (this will create triggers again)
  3. Observe that updating cataloginventory_stock_item.low_stock_date does not create a record in cataloginventory_stock_cl, but does create records in catalogsearch_fulltext_cl and catalog_product_price_cl

Proposed solution

Metadata

Metadata

Labels

Component: MviewFixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentPriority: P1Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing.Progress: doneReported on 2.4.0Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S3Affects non-critical data or functionality and does not force users to employ a workaround.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions