<?xml version="1.0"?>
<!--
/**
 * Copyright © 2023 PT Kemana Teknologi Solusi. All rights reserved.
 * http://www.kemana.com
 */

/**
 * @category Kemana
 * @package  Kemana_ProductCountFix
 * @license  http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 *
 *
 * @author   Evander Reinhart Mulyono <ermulyono@kemana.com>
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <!--
    /**
     * Disable 'update_toolbar_count' plugin
     *
     * This plugin is the reason why the total products count in PLP/search page is incorrect
     *
     * See:
     * - https://github.com/magento/inventory/issues/3360
     * - https://github.com/magento/magento2/issues/35899
     * - https://github.com/magento/magento2/issues/36404
     * - https://stackoverflow.com/questions/74900883/magento-2-category-page-toolbar-showing-wrong-item-count
     *
     * Based on the investigation, it seems like the best way to fix this issue is by disabling the 'update_toolbar_count' plugin.
     * This plugin overrides getTotalNum method from \Magento\Catalog\Block\Product\ProductList\Toolbar (this block method is called in
     * app/design/frontend/Kemana/sidomuncul/Magento_Catalog/templates/product/list/toolbar/amount.phtml)
     *
     * The plugin changes the value by accessing different product collection that is currently used on the page. That is why it outputs
     * different total products count when there is a filter applied. The product collection used for it (inside the plugin) is not filtered.
     */
    -->
    <type name="Magento\Catalog\Block\Product\ProductList\Toolbar">
        <plugin name="update_toolbar_count" disabled="true"/>
    </type>
</config>
