Skip to content

Conversation

@Bashev
Copy link
Contributor

@Bashev Bashev commented Jun 14, 2025

Fix #3630

@Bashev
Copy link
Contributor Author

Bashev commented Jun 14, 2025

This should cover all cases, but if I’ve overlooked anything, please let me know.

Btw, I’m uncertain how to properly address the PHPMD test.

@vahonc
Copy link
Collaborator

vahonc commented Jun 14, 2025

@Bashev,

Hot fix: just to add @SuppressWarnings(PHPMD.CouplingBetweenObjects) into the class PHPDoc

Long story: The class has a coupling value of 14, exceeding the recommended limit of 13, making it harder to understand, maintain, and test. Therefore, it's need to refactor the class to reduce the number of dependencies on other classes.

@Bashev Bashev changed the title [WIP] Filter only InStock child products in the products index. Filter only InStock child products in the products index. Jun 14, 2025
Comment on lines +248 to +259
/**
* If Catalog - Inventory - Stock Options - Display of Stock Products is set to NO,
* then exclude this children from the query results.
*/
if (!$this->scopeConfig->getValue(Configuration::XML_PATH_SHOW_OUT_OF_STOCK)) {
$select->joinInner(
['stock' => $inventoryTable],
new \Zend_Db_Expr("child.{$entityIdField} = stock.product_id AND stock.is_in_stock = 1"),
[]
);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hello @Bashev,

Wouldn't this piece of code only do what it is intended to do if

  • not using MSI
  • using MSI but the current storeId corresponds to a store using the default Stock ?

Regards,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably,
to be honest, i not test it with MSI which have multiple sources and stocks.

I'll try to check these scenarios and will come back.

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.

Incorrect results when filtering by the attribute of an out-of-stock child products.

3 participants