EcomDev / magento2-product-preloader

Magento 2 product data preloaded for anticipated data in other components based on currently available product objects.
MIT License
107 stars 12 forks source link

Product Data Pre-Loader

Magento platform code and third-party extensions in a lot of cases produce redundant database queries on product collections load.

This module provides an easy way to pre-load data for product collections like prices, stock data, and many more by using different types of load types. Right now it supports 3 types of loaded product collections:

In order to pre-load data for a product collection, you need to implement EcomDev\ProductDataPreLoader\DataService\DataLoader interface with such methods:

Custom loaders should be added to LoadService object via DI configuration like this:

<type name="EcomDev\ProductDataPreLoader\DataService\LoadService">
    <arguments>
        <argument name="loaders" xsi:type="array">
            <item name="my_custom_loader" xsi:type="object">My\Module\Loader\MyCustomLoader</item>
        </argument>
    </arguments>
</type>

Installation

Given EOL of Composer 1 all new packagist packages are not published for some time. So best way to keep your install up-to-date is to use Composer 2.0.

composer require ecomdev/magento2-product-data-preloader

Usage Example

This sample module implements optimistic preloader for configurable product data without taking into account simple product status for: