I have a magento with multiple store.
I created from the backoffice a bundle product with 2 options containing each one 3 selections of items
This product appears as out of stock in my store frontend.
So, I have been digging to check why the product do not appear as salable.
I managed to locate the issue there
vendor/magento/module-inventory-bundle-product/Model/GetProductSelection.php
but I’m not able to explain it.
public function execute(ProductInterface $product, OptionInterface $option): Collection
{
var_dump($option->getTitle());
$metadata = $this->metadataPool->getMetadata(ProductInterface::class);
$selectionsCollection = $this->collectionFactory->create();
$selectionsCollection->addAttributeToSelect('status');
$selectionsCollection->setFlag('product_children', true);
$selectionsCollection->addFilterByRequiredOptions();
$selectionsCollection->setOptionIdsFilter([$option->getId()]);
$this->selectionCollectionFilterApplier->apply(
$selectionsCollection,
'parent_product_id',
$product->getData($metadata->getLinkField())
);
var_dump(count(selectionsCollection));
return $selectionsCollection;
}
When I’m in backoffice on the corresponding store view, this print
string(8) “Intenses”
int(3)
string(8) “Intenses”
int(3)
Here I already face an issue, cause the second option isn’t the one I expect…though she is printed in the backend so may be this is normal
The real issue comes once i’m in the frontend…it seems that i’m not able to find again the selection associated to the product on the store; and I also only iterate on the first one
Any ideas what I could miss there ?