Skip to content

The export of the catalog crashes when a bundle does not have a "Is Default" item #60

@xaviermarchegay

Description

@xaviermarchegay

When a bundle does not have a "Is Default" item, we keep hitting the "continue" line 798.

if (count($optionIds) > 1) {
foreach ($selectionCollection as $selection) {
if (!$selection->getIsDefault()) {
continue;
}
$bundleOptions[$selection->getOptionId()][] = [
'product_id' => (int) $selection->getProductId(),
'default_qty' => (int) $selection->getSelectionQty()
];
}

Then $bundleOptions ends up being an empty array.

That means that $quantities remains being an empty array.

$quantities = [];
$bundleOptions = $this->getBundleOptionsProductIds($this->product);
foreach ($bundleOptions as $option) {
foreach ($option as $dataProduct) {
$productId = $dataProduct['product_id'];
$defaultQty = ($dataProduct['default_qty'] > 0) ? $dataProduct['default_qty'] : 1;
$stockQty = $this->stockRegistry->getStockItem($productId, $this->store->getId())->getQty();
$quantities[$productId] = floor($stockQty / $defaultQty);
}
}
return min($quantities) > 0 ? (int) min($quantities) : 0;;

And finally the "min" line 766 crashes because it is not allowed.

min(): Argument #1 ($value) must contain at least one element

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions