719-286-0751 [email protected]

Magento 2.3 – Fix GraphQL Does Not Reflect Catalog Rule Discounts

By default, the Magento 2.3.x GraphQL modules do not appear to reflect Catalog Price Rules

Copying the XML configuration files found in vendor/magento/module-catalog-rule/etc/webapi_rest/*.xml into a custom module in the etc/graphql area appears to resolve this issue:


# etc/graphql/events.xml
<?xml version="1.0"?>
    <!--
    /**
     * Copyright © Magento, Inc. All rights reserved.
     * See COPYING.txt for license details.
     */
    -->
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
        <event name="catalog_product_get_final_price">
            <observer name="catalogrule" instance="Magento\CatalogRule\Observer\ProcessFrontFinalPriceObserver" />
        </event>
        <event name="prepare_catalog_product_collection_prices">
            <observer name="catalogrule" instance="Magento\CatalogRule\Observer\PrepareCatalogProductCollectionPricesObserver" />
        </event>
    </config>

# etc/graphql/di.xml
<?xml version="1.0"?>
    <!--
    /**
     * Copyright © Magento, Inc. All rights reserved.
     * See COPYING.txt for license details.
     */
    -->
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
        <type name="Magento\Catalog\Model\Product">
            <plugin name="apply_catalog_rules_after_product_save_and_reindex" type="Magento\CatalogRule\Plugin\Indexer\Product\Save\ApplyRulesAfterReindex"/>
        </type>
    </config>

Submit a Comment

Your email address will not be published. Required fields are marked *

Install our webapp on your iPhone! Tap and then Add to homescreen.
Share This