I got a problem loading ALL "child" products of a Configurable Product into a collection, even those that are out of stock.
Like loading the products like this:
$simpleCollection = $configurable->getUsedProductCollection()
->addAttributeToSelect('*')
->addFilterByRequiredOptions();
foreach ($simpleCollection as $simple) {
//$simple->getName();
}
will ignore child products that are out of stock, probably because they're not listed in the price tables, that are joined.
Is there another option without loading all child id's by getChildrenIds and then load each simple product with load?
Best Answer
The problem lies in the call to
addStoreFilter()
ingetUsedProductCollection()
:This adds filters to only show products that are salable in the current store.
If
$configurable
is the type instance of your configurable product, you can unset the store filter like this before callinggetUsedProductCollection()
:Complete solution: