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

Product Flat Indexer IFNULL on nullable datetime attributes fallbacks to global #35499

Closed
1 of 5 tasks
vo1 opened this issue May 19, 2022 · 8 comments
Closed
1 of 5 tasks
Assignees
Labels
Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: needs update Additional information is require, waiting for response

Comments

@vo1
Copy link
Contributor

vo1 commented May 19, 2022

Preconditions and environment

  • Magento version 2.4.3, but I suppose happens on any.
    When you have store/website datetime attribute with global value set by some API call, you cannot have scoped values properly loaded into flat data when they are set to null.
    e.g.
    Product.attribute.global = 2022-05-19T00:00:00
    Product.attribute.store1 = 2022-05-22T00:00:00
    Product.attribute.store2 = NULL (cleared in backend with unchecked "Use default" saves as NULL value into database)

Will work totally fine on product load or when flat index is disabled, but when product flat enabled results in:
catalog_product_flat_1 = 2022-05-22T00:00:00
catalog_product_flat_2 = 2022-05-19T00:00:00

Steps to reproduce

  1. Create new datetime attribute scoped to website or store.
  2. Set its value on global level to some date, eg. 2022-05-19
  3. Open store scope, uncheck "Use default" and clear value so it will be saved as NULL into database
  4. Reindex product flat data.

Expected result

Properly fall back to scoped value when attribute is empty for store/website scope

Actual result

Product flat data for the entity on store will contain global value e.g. 2022-05-19 instead of NULL.

Additional information

ELECT et.row_id,
et.entity_id,
Ifnull(st1.value, t1.value) AS bestelbaar_vanaf,
Ifnull(st2.value, t2.value) AS news_from_date,
Ifnull(st3.value, t3.value) AS news_to_date,
Ifnull(st4.value, t4.value) AS orderable_until,
Ifnull(st5.value, t5.value) AS special_from_date,
Ifnull(st6.value, t6.value) AS special_to_date
FROM catalog_product_entity_tmp_indexer AS et
INNER JOIN catalog_product_entity AS e
ON e.entity_id = et.entity_id
AND ( e.created_in <= '1556550000'
AND e.updated_in > '1556550000' )
LEFT JOIN catalog_product_entity_datetime AS t1

Release note

\Magento\Catalog\Model\Indexer\Product\Flat\TableBuilder::_fillTemporaryTable generates the IFNULL fallbacks.

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

m2-assistant bot commented May 19, 2022

Hi @vo1. Thank you for your report.
To speed up processing of this issue, make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

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:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


⚠️ 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.

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@m2-assistant
Copy link

m2-assistant bot commented May 25, 2022

Hi @engcom-November. 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).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components 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-November engcom-November added the Issue: needs update Additional information is require, waiting for response label May 31, 2022
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Needs Update in Issue Confirmation and Triage Board May 31, 2022
@engcom-November
Copy link

Hi @vo1 ,
Thank you for reporting and collaboration. Verified the issue on magento 2.4-develop branch but cannot able to reproduce the issue with provided steps.
Step 3: We cannot save by clearing the value to be saved as NULL as the attribute is a required/mandatory field.
image
Kindly recheck the issue again on Magento 2.4-develop branch as it is having latest code base / upcoming 2.4.x release and elaborate steps to reproduce if you are still facing issues.
Thank you.

@engcom-November engcom-November added the Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch label May 31, 2022
@vo1
Copy link
Contributor Author

vo1 commented May 31, 2022

Hi.
Make it non-mandatory please and you will see.
Our Magento instance uses datetime attributes to show whether product is available for purchase: a real sales website and a demo website where you can order sample products. Both of those using same attribute, it is normal situation when on sales website product is being sold as backorder but on samples you can order 1 of each directly. Nullable is needed for this to work and it works only when flat index is off.

@engcom-November
Copy link

engcom-November commented Jun 1, 2022

Hi @vo1 ,
Verified the issue again on Magento 2.4-develop branch making the attribute non-mandatory and cannot able to reproduce the issue after reindexing all the indexers.
Attribute value is null in store scope view which has been set before and value displayed as expected in global scope as well.
image
Also as per Magento devdocs, catalog_product_flat is not listed in the supported indexers.
Please check the supported indexers using bin/magento indexer:info
image
Kindly recheck the issue again on latest Magento code base / 2.4-develop and provide missing steps if any if the issue is still reproducible.
Thank you.

@engcom-November
Copy link

Hi @vo1 ,
We are closing this issue as there has been no latest update on the same. Kindly reopen/ create new issue if you are still facing any issues.
Thank you.

@thampe
Copy link

thampe commented Aug 19, 2022

Hi,

could you reopen the issue? You can find the issue, if you take a look inside the implementation.

https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Catalog/Model/Indexer/Product/Flat/TableBuilder.php#L333

SELECT `et`.`entity_id`, IFNULL(st1.value, t1.value) AS `description` FROM `catalog_product_entity_tmp_indexer` AS `et`
 INNER JOIN `catalog_product_entity` AS `e` ON e.entity_id = et.entity_id
 LEFT JOIN `catalog_product_entity_text` AS `t1` ON e.entity_id = t1.entity_id AND t1.attribute_id = 72 AND t1.store_id = 0
 LEFT JOIN `catalog_product_entity_text` AS `st1` ON e.entity_id = st1.entity_id AND st1.attribute_id = 72 AND st1.store_id = 1
...

The sql query clearly has an IFNULL(st1.value, t1.value) check and defaults to the value from the admin store if store value is null. Which is the case if you override it in the storeview with an empty value. So the described case ist a valid case, even if you can be not reproduce the issue directly.

Regarding your problem:

Also as per Magento devdocs, catalog_product_flat is not listed in the supported indexers.
Please check the supported indexers using bin/magento indexer:info

You need to enable the flat index, there is also a support doument for that: https://docs.magento.com/user-guide/catalog/catalog-flat.html

Thanks!

@thampe
Copy link

thampe commented Oct 4, 2022

Hi @engcom-November,

could you reopen the issue? Details you can find in my comment above.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: needs update Additional information is require, waiting for response
Projects
None yet
Development

No branches or pull requests

3 participants