Skip to content

Commit

Permalink
Fix stock behavior for grouped products
Browse files Browse the repository at this point in the history
Fixing issue #68 (grouped products should be in stock if at least one child is in stock)
  • Loading branch information
pmzandbergen authored and ah-net committed Jul 31, 2024
1 parent 3c250f3 commit 2b8525b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Traits/Stock/HasStockThroughChildren.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Tweakwise\Magento2TweakwiseExport\Model\StockItem;
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
use Magento\GroupedProduct\Model\Product\Type\Grouped;

/**
* Trait HasChildren
Expand Down Expand Up @@ -40,7 +41,8 @@ public function getStockItem(): ?StockItem
$qty = (int) array_sum($childQty);
$isInStock = min(
max($childStockStatus),
$this->getTypeId() === Configurable::TYPE_CODE ? 1 : $this->stockItem->getIsInStock()
in_array($this->getTypeId(), [Configurable::TYPE_CODE, Grouped::TYPE_CODE], true) ? 1
: $this->stockItem->getIsInStock()
);
$stockItem = new StockItem();
$stockItem->setQty($qty);
Expand Down

0 comments on commit 2b8525b

Please sign in to comment.