lucid-modules/module-indexer-config

优化 Magento 2 索引器批量大小

安装: 104

依赖: 0

建议: 0

安全: 0

星标: 3

观察者: 1

分支: 1

开放问题: 0

类型:magento2-module

dev-master 2023-10-06 08:00 UTC

This package is auto-updated.

Last update: 2024-09-06 10:11:54 UTC


README

MaintainabilityTest Coverage

此模块展示了如何优化 Magento 2 索引器批量大小。将其作为您电子商务的模板使用,并尝试调整批量大小以满足您的需求。

较大的批量可能会消耗更多服务器资源,但在特定情况下可能会更快地处理。

使用方法

根据您的需求更新 etc/di.xml 文件中的 batchRowsCount 值。在此,批量大小设置为 1000 用于可配置产品。这意味着一次索引迭代将加载多达 1000 个产品。

<type name="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\BatchSizeCalculator">
    <arguments>
        <argument name="batchRowsCount" xsi:type="array">
            <item name="configurable" xsi:type="number">1000</item>
        </argument>
    </arguments>
</type>

此模块仅包含基本的产品类型。除了 configurable 之外,还有其他产品类型:groupedbundle。在 Magento 核心di.xml文件中查找类似的类名,以发现其他索引器批量设置。

例如,在 Magento Bundle 模块中,您可以找到以下配置

<type name="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\BatchSizeCalculator">
    <arguments>
        <argument name="estimators" xsi:type="array">
            <item name="bundle" xsi:type="object">Magento\Catalog\Model\Indexer\Price\CompositeProductBatchSizeManagement</item>
        </argument>
        <argument name="batchSizeAdjusters" xsi:type="array">
            <item name="bundle" xsi:type="object">Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\CompositeProductBatchSizeAdjuster</item>
        </argument>
    </arguments>
</type>

将所需的配置复制到您的模块 di.xml 中。请记住在 etc/module.xml 中添加对新模块的依赖关系

<sequence>
    <module name="Magento_Catalog"/>
    <module name="Magento_CatalogInventory"/>
    <module name="Magento_Bundle"/>
</sequence>

使用 Composer 安装

composer require lucid-modules/module-indexer-config