\StockManagerCore

StockManager : implementation of StockManagerInterface

Summary

Methods
Properties
Constants
isAvailable()
addProduct()
removeProduct()
getProductPhysicalQuantities()
getProductRealQuantities()
transferBetweenWarehouses()
getProductCoverage()
getStockByCarrier()
No public properties found
No constants found
calculateWA()
getStockCollection()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

isAvailable()

isAvailable() : \StockManagerInterface

Checks if the StockManager is available

Returns

\StockManagerInterface

addProduct()

addProduct(integer  $id_product, integer  $id_product_attribute, \Warehouse  $warehouse, integer  $quantity,   $id_stock_mvt_reason, float  $price_te, boolean  $is_usable = true, integer  $id_supply_order = null,   $id_employee = null) : boolean

For a given product, adds a given quantity

Parameters

integer $id_product
integer $id_product_attribute
\Warehouse $warehouse
integer $quantity
$id_stock_mvt_reason
float $price_te
boolean $is_usable
integer $id_supply_order

optionnal

$id_employee

Returns

boolean

removeProduct()

removeProduct(integer  $id_product,   $id_product_attribute = null, \Warehouse  $warehouse, integer  $quantity,   $id_stock_mvt_reason, boolean  $is_usable = true, integer  $id_order = null,   $ignore_pack,   $id_employee = null) : array

For a given product, removes a given quantity

Parameters

integer $id_product
$id_product_attribute
\Warehouse $warehouse
integer $quantity
$id_stock_mvt_reason
boolean $is_usable
integer $id_order

Optionnal

$ignore_pack
$id_employee

Returns

array —
  • empty if an error occurred | details of removed products quantities with corresponding prices otherwise

getProductPhysicalQuantities()

getProductPhysicalQuantities(integer  $id_product, integer  $id_product_attribute, array|integer  $ids_warehouse = null, boolean  $usable = false) : integer

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

Parameters

integer $id_product
integer $id_product_attribute
array|integer $ids_warehouse

optional

boolean $usable

false default - in this case we retrieve all physical quantities, otherwise we retrieve physical quantities flagged as usable

Returns

integer

getProductRealQuantities()

getProductRealQuantities(integer  $id_product, integer  $id_product_attribute, array|integer  $ids_warehouse = null, boolean  $usable = false) : integer

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

Parameters

integer $id_product
integer $id_product_attribute
array|integer $ids_warehouse

optional

boolean $usable

false by default

Returns

integer

transferBetweenWarehouses()

transferBetweenWarehouses(integer  $id_product, integer  $id_product_attribute, integer  $quantity,   $id_warehouse_from,   $id_warehouse_to, boolean  $usable_from = true, boolean  $usable_to = true) : boolean

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

Parameters

integer $id_product
integer $id_product_attribute
integer $quantity
$id_warehouse_from
$id_warehouse_to
boolean $usable_from

Optional, true by default

boolean $usable_to

Optional, true by default

Returns

boolean

getProductCoverage()

getProductCoverage(integer  $id_product, integer  $id_product_attribute, integer  $coverage, integer  $id_warehouse = null) : integer

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)

Parameters

integer $id_product
integer $id_product_attribute
integer $coverage
integer $id_warehouse

Optional

Returns

integer —

number of days left (-1 if infinite)

getStockByCarrier()

getStockByCarrier(integer  $id_product, integer  $id_product_attribute, array  $delivery_option = null) : integer

For a given product, retrieves the stock in function of the delivery option

Parameters

integer $id_product
integer $id_product_attribute

optional

array $delivery_option

Returns

integer —

quantity

calculateWA()

calculateWA(\Stock|\PrestaShopCollection  $stock, integer  $quantity, float  $price_te) : integer

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)

Parameters

\Stock|\PrestaShopCollection $stock
integer $quantity
float $price_te

Returns

integer —

WA

getStockCollection()

getStockCollection(integer  $id_product, integer  $id_product_attribute, integer  $id_warehouse = null, integer  $price_te = null) : \PrestaShopCollection

For a given product, retrieves the stock collection

Parameters

integer $id_product
integer $id_product_attribute
integer $id_warehouse

Optional

integer $price_te

Optional

Returns

\PrestaShopCollection —

Collection of Stock