Skip to content

Conversation

@brucemead
Copy link
Contributor

Description (*)

Within the reindexing process there is a bug which results in a delete query to be called for every out of stock product during a full or partial reindex.

Steps to reproduce (*)

  1. Ensure that display out of stock products option is disabled
  2. php bin/magento indexer:reindex catalog_product_price
  3. php bin/magento cron:run --group=index

Fixed Issues (if relevant)

  1. Price Indexer Performance Issue With Out of Stock Products #24414: Price Indexer Performance Issue With Out of Stock Products

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)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Sep 2, 2019

Hi @brucemead. Thank you for your contribution
Here is 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.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

$select->where('stock_item.use_config_manage_stock = 0 AND stock_item.manage_stock = 1');
}

if ($entityIds !== null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the null check is not needed and can be removed, simplifying code: the $entityIds parameter has declared type so in case the $entityIds parameter of modifyPrice() function is null, PHP would throw a fatal error.

@aleron75 aleron75 self-assigned this Sep 4, 2019
Copy link
Contributor

@sidolov sidolov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brucemead please, apply changes suggested by @aleron75

@ghost ghost assigned sidolov Sep 4, 2019
}

if ($entityIds !== null) {
if (count($entityIds) > 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we should count elements here? $entityIds always array, let's use $select->where('stock_item.product_id in (?)', $entityIds) in all cases if array is not empty

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah fair point I copied the implementation from here Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query\BaseFinalPrice::getQuery

@southerncomputer
Copy link
Contributor

might be faster if you intval $entityids too!

also pull against the same thing in vendor/magento/module-catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php as it uses this same routine but with a between min/max(entityIds) which is horribly wrong to do for a list of 100 entityids (think 2000 and 2Million) over and over again!

@sidolov
Copy link
Contributor

sidolov commented Sep 19, 2019

@brucemead , I am closing this PR now due to inactivity.
Please reopen and update if you wish to continue.
Thank you for the collaboration!

@sidolov sidolov closed this Sep 19, 2019
@m2-assistant
Copy link

m2-assistant bot commented Sep 19, 2019

Hi @brucemead, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

- Relates to issue magento#24414
- Made changes based on feedback on PR
@brucemead
Copy link
Contributor Author

@sidolov I've pushed the suggested changes now. Sorry for the slow turn around I've been on leave recently.

Thanks,
Bruce

@brucemead brucemead reopened this Sep 19, 2019
@ghost ghost unassigned aleron75 and sidolov Sep 19, 2019
@ghost ghost assigned sidolov Sep 20, 2019
@ghost ghost removed the Progress: needs update label Sep 20, 2019
@sidolov sidolov added the Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests label Sep 20, 2019
@ghost ghost assigned aleron75 Sep 21, 2019
@magento-engcom-team
Copy link
Contributor

Hi @aleron75, thank you for the review.
ENGCOM-5910 has been created to process this Pull Request

@brucemead
Copy link
Contributor Author

@engcom-Alfa
Copy link
Contributor

✔️ QA Passed

@sidolov sidolov added Auto-Tests: Covered All changes in Pull Request is covered by auto-tests and removed Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests labels Oct 1, 2019
@magento-engcom-team magento-engcom-team merged commit a73b832 into magento:2.3-develop Oct 3, 2019
@m2-assistant
Copy link

m2-assistant bot commented Oct 3, 2019

Hi @brucemead, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@magento-engcom-team magento-engcom-team added this to the Release: 2.3.4 milestone Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants