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

Fix typo which trigger performance bug #35216

Merged

Conversation

VladyslavSikailo
Copy link
Contributor

@VladyslavSikailo VladyslavSikailo commented Mar 23, 2022

Description

Fix typo which triggers bug when Category Products Count cannot be taken from catalog_category_product_index table

Manual testing scenarios

  1. Go to admin->catalog->category
  2. see products count on the category tree
  3. make sure category products count is correct

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

Resolved issues:

  1. resolves [Issue] Fix typo which trigger performance bug #35417: Fix typo which trigger performance bug

Fix bug when Category Products Count cannot be taken from catalog_category_product_index table
@m2-assistant
Copy link

m2-assistant bot commented Mar 23, 2022

Hi @Dren7755. Thank you for your contribution
Here are some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here

ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.

For more details, review the Magento Contributor Guide documentation.

⚠️ According to the Magento Contribution requirements, all Pull Requests 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 Pull Requests 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

@nuzil
Copy link
Contributor

nuzil commented Apr 6, 2022

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@nuzil nuzil self-requested a review April 6, 2022 13:58
@nuzil nuzil added the Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests label Apr 6, 2022
@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

4 similar comments
@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@sdzhepa sdzhepa added the Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. label Apr 14, 2022
@engcom-Alfa
Copy link
Contributor

Thanks for the contribution @Dren7755 and @nuzil !

Tried to reproduce the issue in 2.4-develop version before testing the given PR fix code referring PR description/ comments.
Issue is not reproducible and below is the information on this:

Pre Conditions

  1. Installed a fresh 2.4-develop version in my local with sample data Also had created a new category and added some products in a last ~15 days.

Reproducible steps

  1. Navigated to Admin side: Catalog > Categories > Selected the category and Expanded the Products in Category section.
  2. Counted the total number of products that were displayed in the grid and noted.
  3. Also checked the total number count visible in the same grid section.
  4. Front end: Opened the same category page and counted the products displayed in the list page. Also checked the total count displayed in the page.

Expected Issue as per PR description/ comments:

There should be a mis-match in the products count.

Actual Result

Found same count displayed and products count actually available in all the pages mentioned in steps.
image

As per the description, if my way of execution to identify the issue is deviated, kindly instruct me the correct approach to reproduce the issue in 2.4-develop code.
May be due to any particular way of adding products resulted you in the products count mis-match or might be any other particular reason too!
Kindly help me providing more information please!

@engcom-Alfa
Copy link
Contributor

@magento run Functional Tests CE, Integration Tests, Static Tests

@engcom-Alfa engcom-Alfa self-assigned this Apr 18, 2022
@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Echo
Copy link
Contributor

@magento run Functional Tests B2B

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Echo
Copy link
Contributor

@magento run Functional Tests B2B

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Echo
Copy link
Contributor

@magento run Functional Tests EE

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Echo
Copy link
Contributor

Failing Functional Tests CE is due to currency conerter API is down.
Functional Tests EE and B2B are random failure as on last 3 run different test failed.

Functional Tests EE

  • Run 1
    image

  • Run 2
    image

  • Run3
    image

Functional Tests B2B

  • Run 1
    image

  • Run 2
    image

  • Run 3
    image

Hence moving to Merge In Progress

@VladyslavSikailo
Copy link
Contributor Author

VladyslavSikailo commented Dec 23, 2022

It took 8 months to merge 🤣

Finally, thank you, guys!

@VladyslavSikailo VladyslavSikailo deleted the patch-2 branch December 23, 2022 10:11
@Nuranto
Copy link
Contributor

Nuranto commented Jan 4, 2023

I just applied this patch, and run before/after tests, and it does not improve anything. I still have the same huge number of DB call to count products. (tested on global scope, and on a store scope, on a magento 2.4.5-p1 instance)

It seems the fetchPair is always retrieving data from catalog_category_product_index, which is an obsolete table that is no longer filled by indexers. Therefore, the array is always empty, and the typo-fix doesn't change anything.

See my previous comment : #35216 (comment)

Am I wrong somewhere ? Can we have other feedback on this patch ?

@Nuranto
Copy link
Contributor

Nuranto commented Jan 25, 2023

@VladyslavSikailo can you have a look at my comment above ?

@Nuranto
Copy link
Contributor

Nuranto commented Jun 27, 2023

Hello @engcom-Hotel and @engcom-Alfa,

I think this comment and latests comments here should get your attention since #35216 is now in 2.4.7-beta... I'm pretty sure it does not solve anything.

Also, this is probably related to #15187 too.

@sandipklevu
Copy link

Even with this MR merged, opening Catalog > Categories from admin throws the below error.
It only happens if you are using table prefix in DB.

Issue:

Exception #0 (Magento\Framework\DB\Adapter\TableNotFoundException): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'magento.catalog_category_product_index' doesn't exist, query was: SELECT `cat_index`.`category_id`, count(cat_index.product_id) AS `count` FROM `catalog_category_product_index` AS `cat_index` WHERE (cat_index.category_id in (3))
Exception #1 (Zend_Db_Statement_Exception): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'magento.catalog_category_product_index' doesn't exist, query was: SELECT `cat_index`.`category_id`, count(cat_index.product_id) AS `count` FROM `catalog_category_product_index` AS `cat_index` WHERE (cat_index.category_id in (3))
Exception #2 (PDOException): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'magento.catalog_category_product_index' doesn't exist

Statement to check. Although, $connections have a getTableName() method.
Link

$categoryTable = $connections->getTableName('catalog_category_product_index');

This should be as follows:

$categoryTable = $this->_resource->getTableName('catalog_category_product_index');

Not an issue with this MR, but there is definitely an issue with some of the getTableName() Magento methods from some of the class.

@Nuranto
Copy link
Contributor

Nuranto commented Jul 7, 2023

Even with this change, the original problem still persists : catalog_category_product_index is never filled with any data, since this is an obsolete table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests Component: Catalog Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: accept Project: Community Picked PRs upvoted by the community Release Line: 2.4
Projects
Status: Recently Merged
Development

Successfully merging this pull request may close these issues.

[Issue] Fix typo which trigger performance bug