Added product inventory levels to BundleOption - can be used to display out of stock bundle items in front end
This commit is contained in:
parent
e189a4fa80
commit
7cf6cdb9f0
|
|
@ -35,6 +35,9 @@ class BundleOption extends AbstractProduct
|
|||
{
|
||||
$options = [];
|
||||
|
||||
# eager load all inventories for bundle options
|
||||
$this->product->bundle_options->load('bundle_option_products.product.inventories');
|
||||
|
||||
foreach ($this->product->bundle_options as $option) {
|
||||
$options[$option->id] = $this->getOptionItemData($option);
|
||||
}
|
||||
|
|
@ -87,6 +90,8 @@ class BundleOption extends AbstractProduct
|
|||
'product_id' => $bundleOptionProduct->product_id,
|
||||
'is_default' => $bundleOptionProduct->is_default,
|
||||
'sort_order' => $bundleOptionProduct->sort_order,
|
||||
'in_stock' => $bundleOptionProduct->product->inventories->sum('qty') >= $bundleOptionProduct->qty,
|
||||
'inventory' => $bundleOptionProduct->product->inventories->sum('qty'),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue