Skip to content

Latest commit

 

History

History
1824 lines (950 loc) · 44.9 KB

class.StockAvailableCore.md

File metadata and controls

1824 lines (950 loc) · 44.9 KB

Class StockAvailableCore

Represents quantities available It is either synchronized with Stock or manualy set by the seller

Contents

Properties

Methods

Properties

$definition

public mixed $definition = array('table' => 'stock_available', 'primary' => 'id_stock_available', 'fields' => array('id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'id_product_attribute' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_shop_group' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'quantity' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true), 'depends_on_stock' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true), 'out_of_stock' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true)))

$depends_on_stock

public boolean $depends_on_stock = false

$id_product

public integer $id_product

$id_product_attribute

public integer $id_product_attribute

$id_shop

public integer $id_shop

$id_shop_group

public integer $id_shop_group

$out_of_stock

public boolean $out_of_stock = false

$quantity

public integer $quantity

$webserviceParameters

protected mixed $webserviceParameters = array('fields' => array('id_product' => array('xlink_resource' => 'products'), 'id_product_attribute' => array('xlink_resource' => 'combinations'), 'id_shop' => array('xlink_resource' => 'shops'), 'id_shop_group' => array('xlink_resource' => 'shop_groups')), 'hidden_fields' => array(), 'objectMethods' => array('add' => 'addWs', 'update' => 'updateWs'))

$db

protected \Db $db = false

$def

protected array $def

$fieldsRequired

protected mixed $fieldsRequired = array()

$fieldsRequiredDatabase

protected mixed $fieldsRequiredDatabase = null

$fieldsRequiredLang

protected mixed $fieldsRequiredLang = array()

$fieldsSize

protected mixed $fieldsSize = array()

$fieldsSizeLang

protected mixed $fieldsSizeLang = array()

$fieldsValidate

protected mixed $fieldsValidate = array()

$fieldsValidateLang

protected mixed $fieldsValidateLang = array()

$get_shop_from_context

protected mixed $get_shop_from_context = true

$id

public integer $id

$id_lang

protected integer $id_lang = null

$id_shop_list

public mixed $id_shop_list = null

$identifier

protected mixed $identifier

$image_dir

protected string $image_dir = null

$image_format

protected string $image_format = 'jpg'

$table

protected mixed $table

$tables

protected mixed $tables = array()

$update_fields

protected array $update_fields = null

Methods

__construct

mixed ObjectModelCore::__construct(integer $id, integer $id_lang, integer $id_shop)

Build object

Arguments

  • $id integer - Existing object id in order to load object (optional)
  • $id_lang integer - Required if object is multilingual (optional)
  • $id_shop integer - ID shop for objects with multishop on langs

add

mixed StockAvailableCore::add($autodate, $null_values)

Upgrades total_quantity_available after having saved

Arguments

  • $autodate mixed
  • $null_values mixed

addFieldsRequiredDatabase

mixed ObjectModelCore::addFieldsRequiredDatabase($fields)

Arguments

  • $fields mixed

addSqlShopParams

mixed StockAvailableCore::addSqlShopParams(array $params, integer $id_shop)

Add sql params for shops fields - specific to StockAvailable

Arguments

  • $params array - Reference to the params array
  • $id_shop integer - Optional : The shop ID

addSqlShopRestriction

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

Add an sql restriction for shops fields - specific to StockAvailable

Arguments

  • $sql DbQuery
  • $shop mixed
  • $alias string - Optional : The current table alias

associateTo

boolean ObjectModelCore::associateTo(integer|array $id_shops)

This function associate an item to its context

Arguments

  • $id_shops integer|array

cacheFieldsRequiredDatabase

mixed ObjectModelCore::cacheFieldsRequiredDatabase()

clearCache

mixed ObjectModelCore::clearCache($all)

Arguments

  • $all mixed

copyStockAvailableFromShopToShop

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

Copies stock available content table

Arguments

  • $src_shop_id integer
  • $dst_shop_id integer

delete

boolean ObjectModelCore::delete()

Delete current object from database

deleteImage

boolean ObjectModelCore::deleteImage($force_delete)

Delete images associated with the object

Arguments

  • $force_delete mixed

deleteSelection

boolean ObjectModelCore::deleteSelection(array $selection)

Delete several objects from database

Arguments

  • $selection array

dependsOnStock

boolean StockAvailableCore::dependsOnStock(integer $id_product, integer $id_shop)

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

Arguments

  • $id_product integer
  • $id_shop integer - Optional : gets context if null @see Context::getContext()

displayFieldName

mixed ObjectModelCore::displayFieldName($field, $class, $htmlentities, \Context $context)

Arguments

  • $field mixed
  • $class mixed
  • $htmlentities mixed
  • $context Context

duplicateObject

\new ObjectModelCore::duplicateObject()

Duplicate current object to database

duplicateShops

mixed ObjectModelCore::duplicateShops($id)

Arguments

  • $id mixed

existsInDatabase

boolean ObjectModelCore::existsInDatabase(integer $id_entity, string $table)

Specify if an ObjectModel is already in database

Arguments

  • $id_entity integer
  • $table string

formatFields

array ObjectModelCore::formatFields(integer $type, integer $id_lang)

Arguments

  • $type integer - FORMAT_COMMON or FORMAT_LANG or FORMAT_SHOP
  • $id_lang integer - If this parameter is given, only take lang fields

formatValue

mixed ObjectModelCore::formatValue(mixed $value, integer $type, $with_quotes, $purify)

Format a data

Arguments

  • $value mixed
  • $type integer
  • $with_quotes mixed
  • $purify mixed

getAssociatedShops

array ObjectModelCore::getAssociatedShops()

Get the list of associated id_shop

getDefinition

array ObjectModelCore::getDefinition(string $class, string $field)

Get object definition

Arguments

  • $class string - Name of object
  • $field string - Name of field if we want the definition of one field only

getFieldByLang

mixed ObjectModelCore::getFieldByLang($field_name, null $id_lang)

Return the field value for the specified language if the field is multilang, else the field value.

Arguments

  • $field_name mixed
  • $id_lang null

getFields

array ObjectModelCore::getFields()

Prepare fields for ObjectModel class (add, update) All fields are verified (pSQL, intval.

..)

getFieldsLang

array ObjectModelCore::getFieldsLang()

Prepare multilang fields

getFieldsRequiredDatabase

mixed ObjectModelCore::getFieldsRequiredDatabase($all)

Arguments

  • $all mixed

getFieldsShop

array ObjectModelCore::getFieldsShop()

Prepare fields for multishop Fields are not validated here, we considere they are already validated in getFields() method, this not the best solution but this is the only one possible for retro compatibility.

getQuantityAvailableByProduct

integer StockAvailableCore::getQuantityAvailableByProduct(integer $id_product, integer $id_product_attribute, integer $id_shop)

For a given id_product and id_product_attribute, gets its stock available

Arguments

  • $id_product integer
  • $id_product_attribute integer - Optional
  • $id_shop integer - Optional : gets context by default

getStockAvailableIdByProductId

mixed StockAvailableCore::getStockAvailableIdByProductId($id_product, $id_product_attribute, $id_shop)

Arguments

  • $id_product mixed
  • $id_product_attribute mixed
  • $id_shop mixed

getTranslationsFields

mixed ObjectModelCore::getTranslationsFields($fields_array)

Arguments

  • $fields_array mixed

getValidationRules

array ObjectModelCore::getValidationRules(string $class)

Returns object validation rules (fields validity)

Arguments

  • $class string - Child class name for static use (optional)

getWebserviceObjectList

mixed ObjectModelCore::getWebserviceObjectList($sql_join, $sql_filter, $sql_sort, $sql_limit)

Arguments

  • $sql_join mixed
  • $sql_filter mixed
  • $sql_sort mixed
  • $sql_limit mixed

getWebserviceParameters

mixed ObjectModelCore::getWebserviceParameters($ws_params_attribute_name)

Arguments

  • $ws_params_attribute_name mixed

hasMultishopEntries

boolean ObjectModelCore::hasMultishopEntries()

Check if there is more than one entries in associated shop table for current entity

hydrate

mixed ObjectModelCore::hydrate(array $data, integer $id_lang)

Fill an object with given data. Data must be an array with this syntax: array(objProperty => value, objProperty2 => value, etc.)

Arguments

  • $data array
  • $id_lang integer

hydrateCollection

array ObjectModelCore::hydrateCollection(string $class, array $datas, integer $id_lang)

Fill (hydrate) a list of objects in order to get a collection of these objects

Arguments

  • $class string - Class of objects to hydrate
  • $datas array - List of data (multi-dimensional array)
  • $id_lang integer

isAssociatedToShop

boolean ObjectModelCore::isAssociatedToShop(integer $id_shop)

Check if current object is associated to a shop

Arguments

  • $id_shop integer

isCurrentlyUsed

boolean ObjectModelCore::isCurrentlyUsed(string $table, boolean $has_active_column)

This method is allow to know if a entity is currently used

Arguments

  • $table string - name of table linked to entity
  • $has_active_column boolean - true if the table has an active column

isLangMultishop

mixed ObjectModelCore::isLangMultishop()

isMultiShopField

mixed ObjectModelCore::isMultiShopField($field)

Arguments

  • $field mixed

isMultishop

mixed ObjectModelCore::isMultishop()

makeTranslationFields

mixed ObjectModelCore::makeTranslationFields($fields, $fields_array, $id_language)

Arguments

  • $fields mixed
  • $fields_array mixed
  • $id_language mixed

outOfStock

boolean StockAvailableCore::outOfStock(integer $id_product, integer $id_shop)

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

Arguments

  • $id_product integer
  • $id_shop integer - Optional : gets context if null @see Context::getContext()

postSave

mixed StockAvailableCore::postSave()

Upgrades total_quantity_available after having saved

removeProductFromStockAvailable

mixed StockAvailableCore::removeProductFromStockAvailable(integer $id_product, integer $id_product_attribute, $shop)

Removes a given product from the stock available

Arguments

  • $id_product integer
  • $id_product_attribute integer - Optional
  • $shop mixed

resetProductFromStockAvailableByShopGroup

mixed StockAvailableCore::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

Arguments

  • $shop_group ShopGroup - the ShopGroup object

save

boolean ObjectModelCore::save(boolean $null_values, boolean $autodate)

Save current object to database (add or update)

Arguments

  • $null_values boolean
  • $autodate boolean

setDefinitionRetrocompatibility

mixed ObjectModelCore::setDefinitionRetrocompatibility()

Retrocompatibility for classes without $definition static Remove this in 1.6 !

setFieldsToUpdate

mixed ObjectModelCore::setFieldsToUpdate(array $fields)

Set a list of specific fields to update array(field1 => true, field2 => false, langfield1 => array(1 => true, 2 => false))

Arguments

  • $fields array

setProductDependsOnStock

mixed StockAvailableCore::setProductDependsOnStock(integer $id_product, integer $depends_on_stock, integer $id_shop, $id_product_attribute)

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

Arguments

  • $id_product integer
  • $depends_on_stock integer - Optional : true by default
  • $id_shop integer - Optional : gets context by default
  • $id_product_attribute mixed

setProductOutOfStock

mixed StockAvailableCore::setProductOutOfStock(integer $id_product, integer $out_of_stock, integer $id_shop, $id_product_attribute)

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

Arguments

  • $id_product integer
  • $out_of_stock integer - Optional false by default
  • $id_shop integer - Optional gets context by default
  • $id_product_attribute mixed

setQuantity

mixed StockAvailableCore::setQuantity(integer $id_product, integer $id_product_attribute, $quantity, integer $id_shop)

For a given id_product and id_product_attribute sets the quantity available

Arguments

  • $id_product integer
  • $id_product_attribute integer - Optional
  • $quantity mixed
  • $id_shop integer - Optional

synchronize

mixed StockAvailableCore::synchronize(integer $id_product, $order_id_shop)

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

Arguments

  • $id_product integer
  • $order_id_shop mixed

toggleStatus

boolean ObjectModelCore::toggleStatus()

Toggle object status in database

update

mixed StockAvailableCore::update($null_values)

Upgrades total_quantity_available after having update

Arguments

  • $null_values mixed

updateMultishopTable

boolean ObjectModelCore::updateMultishopTable(string $classname, array $data, string $where, string $specific_where)

Update a table and splits the common datas and the shop datas

Arguments

  • $classname string
  • $data array
  • $where string
  • $specific_where string - Only executed for common table

updateQuantity

mixed StockAvailableCore::updateQuantity(integer $id_product, integer $id_product_attribute, integer $delta_quantity, integer $id_shop)

For a given id_product and id_product_attribute updates the quantity available

Arguments

  • $id_product integer
  • $id_product_attribute integer - Optional
  • $delta_quantity integer - The delta quantity to update
  • $id_shop integer - Optional

updateWs

integer StockAvailableCore::updateWs()

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

validateControler

mixed ObjectModelCore::validateControler($htmlentities)

TODO: refactor rename all calls to this to validateController

Arguments

  • $htmlentities mixed

validateController

mixed ObjectModelCore::validateController($htmlentities)

Arguments

  • $htmlentities mixed

validateField

boolean|string ObjectModelCore::validateField(string $field, mixed $value, integer $id_lang, $skip, $human_errors)

Validate a single field

Arguments

  • $field string - Field name
  • $value mixed - Field value
  • $id_lang integer
  • $skip mixed
  • $human_errors mixed

validateFields

boolean|string ObjectModelCore::validateFields(boolean $die, boolean $error_return)

Check for fields validity before database interaction

Arguments

  • $die boolean
  • $error_return boolean

validateFieldsLang

boolean|string ObjectModelCore::validateFieldsLang(boolean $die, boolean $error_return)

Check for multilingual fields validity before database interaction

Arguments

  • $die boolean
  • $error_return boolean

validateFieldsRequiredDatabase

mixed ObjectModelCore::validateFieldsRequiredDatabase($htmlentities)

Arguments

  • $htmlentities mixed