Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty varchar attribute store level value wrong save in flat catalog #38548

Open
5 tasks
hiren-gujarati opened this issue Mar 23, 2024 · 10 comments
Open
5 tasks
Labels
Area: Product Component: DB Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: ready for dev Reported on 2.4.6 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@hiren-gujarati
Copy link

Preconditions and environment

  • Magento version: 2.4.6
  • Multi store setup
  • Enable Flat Catalog Product
  • Indexer mode: Update by schedule
  • Product attribute (backend_type: varchar, used_in_product_listing: true)

Steps to reproduce

  1. Save varchar attribute value on global scope
  2. Switch to store scope, uncheck Use Default Value checkbox and set empty/blank value in that varchar attribute
  3. Check catalog_product_flat_{store_id} table after re-index data

You can see global scope value in the flat table instated of store scope value but in the EAV table (catalog_product_entity_varchar) you can see store scope value. When indexer mode is set to Update on save then catalog_product_flat_{store_id} table have store scope value.

Expected result

catalog_product_flat_{store_id} should have store scope value when Indexer mode is set Update by schedule.

Actual result

catalog_product_flat_{store_id} have global scope value when product have attribute value on store scope.

Additional information

Product flat re-indexer code have SQL query with getIfNullSql function which might replacing store scope null value with global scope value.
https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Catalog/Model/Indexer/Product/Flat/TableBuilder.php#L333-L337

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

m2-assistant bot commented Mar 23, 2024

Hi @hiren-gujarati. Thank you for your report.
To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:


Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
🕙 You can find the schedule on the Magento Community Calendar page.
📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

@m2-community-project m2-community-project bot added this to Ready for Confirmation in Issue Confirmation and Triage Board Mar 23, 2024
@engcom-Bravo engcom-Bravo added the Reported on 2.4.6 Indicates original Magento version for the Issue report. label Mar 25, 2024
@engcom-Bravo engcom-Bravo self-assigned this Mar 25, 2024
Copy link

m2-assistant bot commented Mar 25, 2024

Hi @engcom-Bravo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • 3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
  • 5. Add label Issue: Confirmed once verification is complete.
  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Bravo
Copy link
Contributor

Hi @hiren-gujarati,

Thanks for your reporting and Collaboration.

As per Magento devdocs https://experienceleague.adobe.com/en/docs/commerce-admin/catalog/catalog/catalog-flat Use of a flat catalog is no longer recommended as a best practice.

Could you please check document and let us know if you are still facing any issue.

Thanks.

@engcom-Bravo engcom-Bravo added the Issue: needs update Additional information is require, waiting for response label Mar 26, 2024
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Needs Update in Issue Confirmation and Triage Board Mar 26, 2024
@hiren-gujarati
Copy link
Author

Hi @engcom-Bravo

As per Magento devdocs, flat catalog is not recommended as a best practice but Magento does not deprecated flat catalog yet.

There are issues related to this which is closed without any resolution,
#9434
#35499

Thanks.

@engcom-Bravo
Copy link
Contributor

Hi @hiren-gujarati,

Thank you for reporting and collaboration.

Verified the issue on Magento 2.4-develop instance and the issue is not reproducible.Kindly refer the screenshots.

Screenshot 2024-03-27 at 15 28 35 Screenshot 2024-03-27 at 15 28 56

catalog_product_flat_{store_id} getting store scope value when Indexer mode is set Update by schedule.

Kindly recheck the issue in Latest Magento 2.4-develop instance and elaborate the steps to reproduce if the issue is still reproducible.

Thanks.

@hiren-gujarati
Copy link
Author

Hi @engcom-Bravo

Seems like you didn't read description properly. I have clearly mentioned attribute which have backend_type varchar, You are checking on attribute with backend_type integer. Also please create store scope attribute, not a global.

Issue is reproducible from 2.1.x to latest Magento version 2.4.x. You can follow below step to reproduce issue.

  1. Create global scope product attribute with backend_type varchar.
  2. Set this attribute value (ex. test) from 'All store view' scope.
  3. Switch to Store scope, uncheck Use Default Value checkbox and set empty/blank value in that attribute.
  4. Flat product is enable from configuration and indexer is set on Update by schedule mode so, after 'indexer_update_all_views' cron run or manual reindex, catalog_product_flat_{store_id} table have 'All store view' value instned of store scope value.

Thanks.

@engcom-Bravo
Copy link
Contributor

Hi @hiren-gujarati,

Thanks for your update.

Verified the issue on Magento 2.4-develop instance and the issue is reproducible.Kindly refer the screenshots.

Screenshot 2024-03-28 at 12 54 44 Screenshot 2024-03-28 at 12 55 00

We are getting 'All store view' value instned of store scope value.

Hence Confirming the issue.

Thanks.

@engcom-Bravo engcom-Bravo added Area: Product and removed Issue: needs update Additional information is require, waiting for response labels Mar 28, 2024
@m2-community-project m2-community-project bot moved this from Needs Update to Ready for Confirmation in Issue Confirmation and Triage Board Mar 28, 2024
@engcom-Bravo engcom-Bravo added Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed and removed Issue: ready for confirmation labels Mar 28, 2024
@engcom-Bravo engcom-Bravo added Priority: P2 A defect with this priority could have functionality issues which are not to expectations. and removed Issue: ready for confirmation labels Mar 28, 2024
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Confirmed in Issue Confirmation and Triage Board Mar 28, 2024
@m2-community-project m2-community-project bot added this to Dev In Progress in High Priority Backlog Mar 28, 2024
@engcom-Bravo engcom-Bravo added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Mar 28, 2024
@m2-community-project m2-community-project bot added this to Dev In Progress in High Priority Backlog Mar 28, 2024
@m2-community-project m2-community-project bot moved this from Dev In Progress to Ready for Development in High Priority Backlog Mar 28, 2024
@engcom-Bravo engcom-Bravo removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Mar 28, 2024
@m2-community-project m2-community-project bot moved this from Ready for Development to Dev In Progress in High Priority Backlog Mar 28, 2024
@engcom-Bravo engcom-Bravo added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Progress: ready for dev and removed Progress: dev in progress labels Mar 28, 2024
@m2-community-project m2-community-project bot moved this from Dev In Progress to Ready for Development in High Priority Backlog Mar 28, 2024
@m2-community-project m2-community-project bot moved this from Dev In Progress to Ready for Development in High Priority Backlog Mar 28, 2024
@hiren-gujarati
Copy link
Author

Hi @engcom-Bravo

Thanks for checking and confirming issue.

I have created following patch for temporary workaround, not sure is it correct approach or not so, attaching patch.

--- a/vendor/magento/module-catalog/Model/Indexer/Product/Flat/TableBuilder.php
+++ b/vendor/magento/module-catalog/Model/Indexer/Product/Flat/TableBuilder.php
@@ -330,7 +330,8 @@
                         []
                     );

-                    $columnValue = $this->_connection->getIfNullSql(
+                    $columnValue = $this->_connection->getCheckSql(
+                        's' . $countTableName . '.value_id',
                         's' . $countTableName . '.value',
                         $countTableName . '.value'
                     );

@engcom-Bravo engcom-Bravo removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Apr 1, 2024
@m2-community-project m2-community-project bot moved this from Ready for Development to Dev In Progress in High Priority Backlog Apr 1, 2024
@engcom-Bravo engcom-Bravo added the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Apr 1, 2024
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.adobe.com/browse/AC-11715 is successfully created for this GitHub issue.

Copy link

m2-assistant bot commented Apr 1, 2024

✅ Confirmed by @engcom-Bravo. Thank you for verifying the issue.
Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@m2-community-project m2-community-project bot moved this from Dev In Progress to Ready for Development in High Priority Backlog Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Product Component: DB Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: ready for dev Reported on 2.4.6 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
High Priority Backlog
  
Ready for Development
Development

No branches or pull requests

3 participants