add function isSaleable, fix error in function getChildrenIds of grouped product

This commit is contained in:
Steffen Mahler 2020-07-27 12:03:50 +02:00
parent a06bca38d4
commit 47cfda1d13
1 changed files with 17 additions and 1 deletions

View File

@ -106,7 +106,7 @@ class Grouped extends AbstractType
*/
public function getChildrenIds()
{
return array_unique($this->product->grouped_products()->pluck('product_id')->toArray());
return array_unique($this->product->grouped_products()->pluck('associated_product_id')->toArray());
}
/**
@ -139,6 +139,22 @@ class Grouped extends AbstractType
return min($minPrices);
}
/**
* @return bool
*/
public function isSaleable()
{
if (!$this->product->status) {
return false;
}
if (ProductFlat::query()->select('id')->whereIn('product_id', $this->getChildrenIds())->where('status', 0)->first()) {
return false;
}
return true;
}
/**
* Get group product special price
*