StockManager : implementation of StockManagerInterface
- Class name: StockManagerCore
- Source: classes/stock/StockManager.php line 31
- This class implements: StockManagerInterface
- addProduct
- calculateWA
- getProductCoverage
- getProductPhysicalQuantities
- getProductRealQuantities
- getStockByCarrier
- getStockCollection
- isAvailable
- removeProduct
- transferBetweenWarehouses
boolean StockManagerCore::addProduct(integer $id_product, integer $id_product_attribute, \Warehouse $warehouse, integer $quantity, integer $id_stock_mvt_reason, float $price_te, boolean $is_usable, integer|null $id_supply_order, \Employee|null $employee)
For a given product, adds a given quantity
- Visibility: public
- Source: classes/stock/StockManager.php line 58
- $id_product integer
- $id_product_attribute integer
- $warehouse Warehouse
- $quantity integer
- $id_stock_mvt_reason integer
- $price_te float
- $is_usable boolean
- $id_supply_order integer|null
- $employee Employee|null
integer StockManagerCore::calculateWA(\Stock|\PrestaShopCollection $stock, integer $quantity, float $price_te)
For a given stock, calculates its new WA(Weighted Average) price based on the new quantities and price Formula : (physicalStock * lastCump + quantityToAdd * unitPrice) / (physicalStock + quantityToAdd)
- Visibility: protected
- Source: classes/stock/StockManager.php line 780
integer StockManagerCore::getProductCoverage($id_product, $id_product_attribute, $coverage, $id_warehouse)
For a given product, returns the time left before being out of stock.
By default, for the given product, it will use sum(quantities removed in all warehouses)
- Visibility: public
- Source: classes/stock/StockManager.php line 726
- $id_product mixed
- $id_product_attribute mixed
- $coverage mixed
- $id_warehouse mixed
mixed StockManagerCore::getProductPhysicalQuantities($id_product, $id_product_attribute, $ids_warehouse, $usable)
For a given product, returns its physical quantity If the given product has combinations and $id_product_attribute is null, returns the sum for all combinations
- Visibility: public
- Source: classes/stock/StockManager.php line 516
- $id_product mixed
- $id_product_attribute mixed
- $ids_warehouse mixed
- $usable mixed
mixed StockManagerCore::getProductRealQuantities($id_product, $id_product_attribute, $ids_warehouse, $usable)
For a given product, returns its real quantity If the given product has combinations and $id_product_attribute is null, returns the sum for all combinations Real quantity : (physical_qty + supply_orders_qty - client_orders_qty) If $usable is defined, real quantity: usable_qty + supply_orders_qty - client_orders_qty
- Visibility: public
- Source: classes/stock/StockManager.php line 551
- $id_product mixed
- $id_product_attribute mixed
- $ids_warehouse mixed
- $usable mixed
integer StockManagerCore::getStockByCarrier(integer $id_product, integer $id_product_attribute, array $delivery_option)
For a given product, retrieves the stock in function of the delivery option
- Visibility: public
- This method is static.
- Source: classes/stock/StockManager.php line 817
- $id_product integer
- $id_product_attribute integer - optional
- $delivery_option array
\PrestaShopCollection StockManagerCore::getStockCollection(integer $id_product, integer $id_product_attribute, integer $id_warehouse, integer $price_te)
For a given product, retrieves the stock collection
- Visibility: protected
- Source: classes/stock/StockManager.php line 794
- $id_product integer
- $id_product_attribute integer
- $id_warehouse integer - Optional
- $price_te integer - Optional
mixed StockManagerCore::isAvailable()
Checks if the StockManager is available
- Visibility: public
- This method is static.
- Source: classes/stock/StockManager.php line 36
array StockManagerCore::removeProduct(integer $id_product, integer|null $id_product_attribute, \Warehouse $warehouse, integer $quantity, integer $id_stock_mvt_reason, boolean $is_usable, integer|null $id_order, integer $ignore_pack, \Employee|null $employee)
For a given product, removes a given quantity
- Visibility: public
- Source: classes/stock/StockManager.php line 217
- $id_product integer
- $id_product_attribute integer|null
- $warehouse Warehouse
- $quantity integer
- $id_stock_mvt_reason integer
- $is_usable boolean
- $id_order integer|null
- $ignore_pack integer
- $employee Employee|null
mixed StockManagerCore::transferBetweenWarehouses($id_product, $id_product_attribute, $quantity, $id_warehouse_from, $id_warehouse_to, $usable_from, $usable_to)
For a given product, transfers quantities between two warehouses By default, it manages usable quantities It is also possible to transfer a usable quantity from warehouse 1 in an unusable quantity to warehouse 2 It is also possible to transfer a usable quantity from warehouse 1 in an unusable quantity to warehouse 1
- Visibility: public
- Source: classes/stock/StockManager.php line 659
- $id_product mixed
- $id_product_attribute mixed
- $quantity mixed
- $id_warehouse_from mixed
- $id_warehouse_to mixed
- $usable_from mixed
- $usable_to mixed