Skip to content

Commit

Permalink
Merge pull request #76 from EmicoEcommerce/beta-3
Browse files Browse the repository at this point in the history
fix: stock behavior for grouped products
fix: type case int to boolean since shouldExportByStock only has boolean as return type
  • Loading branch information
ah-net authored Sep 24, 2024
2 parents 1c282a3 + 1a930c0 commit 9e61b34
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Model/Write/Products/ExportEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ protected function shouldExportByVisibility(): bool
*/
protected function isInStock(): bool
{
return $this->getStockItem() !== null ? $this->getStockItem()->getIsInStock() : false;
return $this->getStockItem() !== null ? (bool) $this->getStockItem()->getIsInStock() : false;
}

/**
Expand Down
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 9e61b34

Please sign in to comment.