Skip to content

2.4.5 EE Graphql Product Collection flat table disabled  #37334

Open
@alexmtch

Description

@alexmtch

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

  1. Enable Use Flat Catalog Category and Use Flat Catalog Product from admin panel on path Stores -> Settings -> Configuration -> Catalog -> Catalog -> Storefront

image

  1. Clear the cache.
  2. Try to add the product to the cart from the frontend, it will return true for isAvailable:

image

  1. But in GraphQL it is returning false:

image

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”.

Metadata

Metadata

Assignees

Labels

Area: CatalogComponent: CatalogIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: dev in progressProject: GraphQLReported on 2.4.5Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions