The stock decorator implements a method which should calculate stock quantity for a given composite exportEntity how much stock there is. This is the method:
/**
* @param ExportEntity $entity
* @param int $storeId
* @return float
*/
private function getCombinedStock(ExportEntity $entity, int $storeId): float
{
$stockQuantities = $this->getStockQuantities($entity);
if (empty($stockQuantities)) {
return 0;
}
switch ($this->config->getStockCalculation($storeId)) {
case StockCalculation::OPTION_MAX:
return max($stockQuantities);
case StockCalculation::OPTION_MIN:
return min($stockQuantities);
case StockCalculation::OPTION_SUM:
default:
return array_sum($stockQuantities);
}
}
This method asks from config how this should be calculated, however this should depend on product type and not on config. The reason is that if config is set to OPTION_MAX then this works fine for a configurable but this does not work at all for a set or bundle, in this case a minimum of all child stock quantities would be better. We propose that each type should have its own class which implements the logic for that entity type.
For reference the value that is calculated ends up in the the feed as {{qty}}.
Issue Brief
The stock decorator implements a method which should calculate stock quantity for a given composite exportEntity how much stock there is. This is the method:
This method asks from config how this should be calculated, however this should depend on product type and not on config. The reason is that if config is set to OPTION_MAX then this works fine for a configurable but this does not work at all for a set or bundle, in this case a minimum of all child stock quantities would be better. We propose that each type should have its own class which implements the logic for that entity type.
For reference the value that is calculated ends up in the the feed as{{qty}} .