Description
Preconditions and environment
- Magento version : 2.4.5 EE
- Anything else that would help a developer reproduce the bug
Steps to reproduce
Go on vendor/magento/module-catalog/Model/ResourceModel/Product/Collection.php
in the addAttributeToSelect
method.
On my project $this->isEnabledFlat()
is always to false causing on some graphql request (add to cart) large execution times dues to vendor/magento/module-quote/Model/ResourceModel/Quote/Item/Collection.php
method _assignProducts
loading all quote_item
attributes.
I found out that in the vendor/magento/module-catalog/Model/ResourceModel/Product/Collection.php
constructor, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState
is passed.
And the $catalogProductFlatState->isAvailable()
method is alway false dues to the $isAvailable
instruction in the constructor false by default.
I found out that in vendor/magento/module-catalog/etc/frontend/di.xml
it's set to true :
<type name="Magento\Catalog\Model\Indexer\AbstractFlatState">
<arguments>
<argument name="isAvailable" xsi:type="boolean">true</argument>
</arguments>
</type>
<type name="Magento\Catalog\Model\Indexer\Product\Flat\State">
<arguments>
<argument name="isAvailable" xsi:type="boolean">true</argument>
</arguments>
</type>
Or this is not set in any [...]/etc/graphql/di.xml
Fixing this on the module-catalog-graphql fix both issues. I dot found the correlation between $catalogProductFlatState and $_flatEnabled but it fix the issue. Maybe someone could give me more explanations...
Steps
- Enable
Use Flat Catalog Category
andUse Flat Catalog Product
from admin panel on pathStores -> Settings -> Configuration -> Catalog -> Catalog -> Storefront
- Clear the cache.
- Try to add the product to the cart from the frontend, it will return
true
forisAvailable
:
- But in GraphQL it is returning
false
:
Expected result
Flat should be enabled for collections on graphql scope
Actual result
Flat is not enabled for collections on graphql scope
Additional information
No response
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.