CoolCMS API

LowStockFilterTrait

"Below minimum" filter across the StockItem/StockLevel grids.

Sum of available (levels) vs. stockItem.minQuantity is an aggregation over a foreign table that the generic DataGrid cannot do (StockLevel is not a mapped collection of the item). It is computed in PHP over managers (no direct SQL across the Admin/Api boundary); use with PrecomputedIdsFilter.

Requires $this->stockItemManager and $this->stockLevelManager in the host (constructor).

Table of Contents

Methods

computeLowStockItemIds()  : array<string|int, int>
n()  : numeric-string
sumLevelsByStockItemId()  : array<int, array{quantity: string, reserved: string}>

Methods

computeLowStockItemIds()

private computeLowStockItemIds() : array<string|int, int>
Return values
array<string|int, int> —

ids of stock items whose sum of available across all warehouses is below minQuantity

n()

private n(string $value) : numeric-string
Parameters
$value : string
Return values
numeric-string —

bcmath wrapper (normalizes a plain string, like Api DocumentService::n()).

sumLevelsByStockItemId()

private sumLevelsByStockItemId(array<string|int, int> $stockItemIds) : array<int, array{quantity: string, reserved: string}>
Parameters
$stockItemIds : array<string|int, int>
Return values
array<int, array{quantity: string, reserved: string}>
On this page

Search results