Properties

$id_product

$id_product : integer

Type

integer — identifier of the current product

$id_product_attribute

$id_product_attribute : integer

Type

integer — identifier of product attribute if necessary

$id_shop

$id_shop : integer

Type

integer — the shop associated to the current product and corresponding quantity

$id_shop_group

$id_shop_group : integer

Type

integer — the group shop associated to the current product and corresponding quantity

$quantity

$quantity : integer

Type

integer — the quantity available for sale

$depends_on_stock

$depends_on_stock : boolean

Type

boolean — determine if the available stock value depends on physical stock

$out_of_stock

$out_of_stock : boolean

Type

boolean — determine if a product is out of stock - it was previously in Product class

$definition

$definition : 

Type

$webserviceParameters

$webserviceParameters : 

Type

Methods

updateWs()

updateWs() : integer

For a given {id_product, id_product_attribute and id_shop}, gets the stock available id associated

Returns

integer

getStockAvailableIdByProductId()

getStockAvailableIdByProductId(  $id_product,   $id_product_attribute = null,   $id_shop = null) 

Parameters

$id_product
$id_product_attribute
$id_shop

synchronize()

synchronize(integer  $id_product,   $order_id_shop = null) 

For a given id_product, synchronizes StockAvailable::quantity with Stock::usable_quantity

Parameters

integer $id_product
$order_id_shop

setProductDependsOnStock()

setProductDependsOnStock(integer  $id_product, integer  $depends_on_stock = true, integer  $id_shop = null,   $id_product_attribute) 

For a given id_product, sets if stock available depends on stock

Parameters

integer $id_product
integer $depends_on_stock

Optional : true by default

integer $id_shop

Optional : gets context by default

$id_product_attribute

setProductOutOfStock()

setProductOutOfStock(integer  $id_product, integer  $out_of_stock = false, integer  $id_shop = null,   $id_product_attribute) 

For a given id_product, sets if product is available out of stocks

Parameters

integer $id_product
integer $out_of_stock

Optional false by default

integer $id_shop

Optional gets context by default

$id_product_attribute

getQuantityAvailableByProduct()

getQuantityAvailableByProduct(integer  $id_product = null, integer  $id_product_attribute = null, integer  $id_shop = null) : integer

For a given id_product and id_product_attribute, gets its stock available

Parameters

integer $id_product
integer $id_product_attribute

Optional

integer $id_shop

Optional : gets context by default

Returns

integer —

Quantity

add()

add(  $autodate = true,   $null_values = false) 

Upgrades total_quantity_available after having saved

Parameters

$autodate
$null_values

update()

update(  $null_values = false) 

Upgrades total_quantity_available after having update

Parameters

$null_values

postSave()

postSave() 

Upgrades total_quantity_available after having saved

updateQuantity()

updateQuantity(integer  $id_product, integer  $id_product_attribute, integer  $delta_quantity, integer  $id_shop = null) 

For a given id_product and id_product_attribute updates the quantity available

Parameters

integer $id_product
integer $id_product_attribute

Optional

integer $delta_quantity

The delta quantity to update

integer $id_shop

Optional

setQuantity()

setQuantity(integer  $id_product, integer  $id_product_attribute,   $quantity, integer  $id_shop = null) 

For a given id_product and id_product_attribute sets the quantity available

Parameters

integer $id_product
integer $id_product_attribute

Optional

$quantity
integer $id_shop

Optional

removeProductFromStockAvailable()

removeProductFromStockAvailable(integer  $id_product, integer  $id_product_attribute = null,   $shop = null) 

Removes a given product from the stock available

Parameters

integer $id_product
integer $id_product_attribute

Optional

$shop

resetProductFromStockAvailableByShopGroup()

resetProductFromStockAvailableByShopGroup(\ShopGroup  $shop_group) 

Removes all product quantities from all a group of shops If stocks are shared, remoe all old available quantities for all shops of the group Else remove all available quantities for the current group

Parameters

\ShopGroup $shop_group

the ShopGroup object

dependsOnStock()

dependsOnStock(integer  $id_product, integer  $id_shop = null) : boolean

For a given product, tells if it depends on the physical (usable) stock

Parameters

integer $id_product
integer $id_shop

Optional : gets context if null @see Context::getContext()

Returns

boolean —

: depends on stock @see $depends_on_stock

outOfStock()

outOfStock(integer  $id_product, integer  $id_shop = null) : boolean

For a given product, get its "out of stock" flag

Parameters

integer $id_product
integer $id_shop

Optional : gets context if null @see Context::getContext()

Returns

boolean —

: depends on stock @see $depends_on_stock

addSqlShopRestriction()

addSqlShopRestriction(\DbQuery  $sql = null,   $shop = null, string  $alias = null) : mixed

Add an sql restriction for shops fields - specific to StockAvailable

Parameters

\DbQuery $sql
$shop
string $alias

Optional : The current table alias

Returns

mixed —

the DbQuery object or the sql restriction string

addSqlShopParams()

addSqlShopParams(array  $params, integer  $id_shop = null) 

Add sql params for shops fields - specific to StockAvailable

Parameters

array $params

Reference to the params array

integer $id_shop

Optional : The shop ID

copyStockAvailableFromShopToShop()

copyStockAvailableFromShopToShop(integer  $src_shop_id, integer  $dst_shop_id) : boolean

Copies stock available content table

Parameters

integer $src_shop_id
integer $dst_shop_id

Returns

boolean