Filter only InStock child products in the products index.#3631
Filter only InStock child products in the products index.#3631Bashev wants to merge 5 commits intoSmile-SA:2.11.xfrom
Conversation
|
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. |
|
Hot fix: just to add 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. |
| /** | ||
| * 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"), | ||
| [] | ||
| ); | ||
| } | ||
|
|
There was a problem hiding this comment.
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,
There was a problem hiding this comment.
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.
Fix #3630