Skip to content

Latest commit

 

History

History
2316 lines (1170 loc) · 51.9 KB

class.CategoryCore.md

File metadata and controls

2316 lines (1170 loc) · 51.9 KB

Class CategoryCore

Contents

Properties

Methods

Properties

$_links

protected mixed $_links = array()

$active

public boolean $active = 1

$date_add

public string $date_add

$date_upd

public string $date_upd

$definition

public mixed $definition = array('table' => 'category', 'primary' => 'id_category', 'multilang' => true, 'multishop' => true, 'fields' => array('nleft' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), 'nright' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), 'level_depth' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true), 'id_parent' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), 'position' => array('type' => self::TYPE_INT), 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 64), 'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 64), 'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString'), 'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128), 'meta_description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), 'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255)))

$description

public string $description

$groupBox

public mixed $groupBox

$id

public mixed $id

$id_category

public integer $id_category

$id_image

public string $id_image = 'default'

$id_parent

public integer $id_parent

$level_depth

public integer $level_depth

$link_rewrite

public string $link_rewrite

$meta_description

public string $meta_description

$meta_keywords

public string $meta_keywords

$meta_title

public string $meta_title

$name

public string $name

$nleft

public integer $nleft

$nright

public integer $nright

$position

public integer $position

$webserviceParameters

protected mixed $webserviceParameters = array('objectsNodeName' => 'categories', 'hidden_fields' => array('nleft', 'nright', 'groupBox'), 'fields' => array('id_parent' => array('xlink_resource' => 'categories'), 'level_depth' => array('setter' => false), 'nb_products_recursive' => array('getter' => 'getWsNbProductsRecursive', 'setter' => false)), 'associations' => array('categories' => array('getter' => 'getChildrenWs', 'resource' => 'category'), 'products' => array('getter' => 'getProductsWs', 'resource' => 'product')))

$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()

$id_lang

protected integer $id_lang = null

$id_shop

protected mixed $id_shop = 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()

Methods

__construct

mixed CategoryCore::__construct($id_category, $id_lang, $id_shop)

Arguments

  • $id_category mixed
  • $id_lang mixed
  • $id_shop mixed

_subTree

mixed CategoryCore::_subTree($categories, $id_category, $n)

Arguments

  • $categories mixed
  • $id_category mixed
  • $n mixed

add

mixed CategoryCore::add($autodate, $nullValues)

Arguments

  • $autodate mixed
  • $nullValues mixed

addFieldsRequiredDatabase

mixed ObjectModelCore::addFieldsRequiredDatabase($fields)

Arguments

  • $fields mixed

addGroups

mixed CategoryCore::addGroups($groups)

Arguments

  • $groups mixed

addGroupsIfNoExist

mixed CategoryCore::addGroupsIfNoExist($id_group)

Arguments

  • $id_group mixed

associateTo

boolean ObjectModelCore::associateTo(integer|array $id_shops, string $type)

This function associate an item to its context

Arguments

  • $id_shops integer|array
  • $type string

calcLevelDepth

integer CategoryCore::calcLevelDepth()

Get the depth level for the category

categoryExists

boolean CategoryCore::categoryExists($id_category)

Specify if a category already in base

Arguments

  • $id_category mixed - Category id

checkAccess

boolean CategoryCore::checkAccess(mixed $id_customer)

checkAccess return true if id_customer is in a group allowed to see this category.

Arguments

  • $id_customer mixed

checkBeforeMove

boolean CategoryCore::checkBeforeMove(integer $id_category, integer $id_parent)

Check if category can be moved in another one.

The category cannot be moved in a child category.

Arguments

  • $id_category integer - current category
  • $id_parent integer - Parent candidate

cleanGroups

mixed CategoryCore::cleanGroups()

cleanPositions

boolean CategoryCore::cleanPositions(mixed $id_category_parent)

cleanPositions keep order of category in $id_category_parent, but remove duplicate position. Should not be used if positions are clean at the beginning !

Arguments

  • $id_category_parent mixed

clearCache

mixed ObjectModelCore::clearCache($all)

Arguments

  • $all mixed

delete

mixed CategoryCore::delete()

deleteImage

boolean ObjectModelCore::deleteImage()

Delete images associated with the object

deleteSelection

mixed CategoryCore::deleteSelection($categories)

Delete several categories from database

return boolean Deletion result

Arguments

  • $categories mixed

displayFieldName

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

Arguments

  • $field mixed
  • $className mixed
  • $htmlentities mixed
  • $context Context

duplicateProductCategories

boolean CategoryCore::duplicateProductCategories(integer $id_old, boolean $id_new)

Copy products from a category to another

Arguments

  • $id_old integer - Source category ID
  • $id_new boolean - Destination category ID

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 $id_lang)

Arguments

  • $id_lang integer - If this parameter is given, only take lang fields

formatValue

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

Format a data

Arguments

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

getAllChildren

\Collection CategoryCore::getAllChildren(integer $id_lang)

Return an array of all children of the current category

Arguments

  • $id_lang integer

getCategories

array CategoryCore::getCategories(integer $id_lang, boolean $active, $order, $sql_filter, $sql_sort, $sql_limit)

Return available categories

Arguments

  • $id_lang integer - Language ID
  • $active boolean - return only active categories
  • $order mixed
  • $sql_filter mixed
  • $sql_sort mixed
  • $sql_limit mixed

getCategoryInformations

Array CategoryCore::getCategoryInformations(Array $ids_category, integer $id_lang)

Arguments

  • $ids_category Array
  • $id_lang integer

getChildren

array CategoryCore::getChildren(integer $id_parent, integer $id_lang, boolean $active)

Arguments

  • $id_parent integer
  • $id_lang integer
  • $active boolean

getChildrenWithNbSelectedSubCat

array CategoryCore::getChildrenWithNbSelectedSubCat(integer $id_parent, $selected_cat, integer $id_lang, \Shop $shop)

This method allow to return children categories with the number of sub children selected for a product

Arguments

  • $id_parent integer
  • $selected_cat mixed
  • $id_lang integer
  • $shop Shop

getChildrenWs

mixed CategoryCore::getChildrenWs()

getDefinition

mixed ObjectModelCore::getDefinition($class, $field)

Arguments

  • $class mixed
  • $field mixed

getDescriptionClean

string CategoryCore::getDescriptionClean($description)

Allows to display the category description without HTML tags and slashes

Arguments

  • $description mixed

getDuplicatePosition

array CategoryCore::getDuplicatePosition()

Search for another category with the same parent and the same position

getEntity

mixed ObjectModelCore::getEntity($entity)

Arguments

  • $entity mixed

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

getGroups

mixed CategoryCore::getGroups()

getHomeCategories

array CategoryCore::getHomeCategories(integer $id_lang, boolean $active)

Return main categories

Arguments

  • $id_lang integer - Language ID
  • $active boolean - return only active categories

getInterval

array CategoryCore::getInterval(integer $id)

Return nleft and nright fields for a given category

Arguments

  • $id integer

getLastPosition

integer CategoryCore::getLastPosition(integer $id_category_parent)

this function return the number of category + 1 having $id_category_parent as parent.

Arguments

  • $id_category_parent integer - the parent category

getLink

mixed CategoryCore::getLink(\Link $link)

Arguments

getLinkRewrite

mixed CategoryCore::getLinkRewrite($id_category, $id_lang)

Arguments

  • $id_category mixed
  • $id_lang mixed

getName

mixed CategoryCore::getName($id_lang)

Arguments

  • $id_lang mixed

getParentsCategories

array CategoryCore::getParentsCategories(integer $id_lang)

Get Each parent category of this category until the root category

Arguments

  • $id_lang integer - Language ID

getProducts

mixed CategoryCore::getProducts(integer $id_lang, integer $p, integer $n, $order_by, $order_way, boolean $get_total, boolean $active, boolean $random, integer $random_number_products, boolean $check_access, \Context $context)

Return current category products

Arguments

  • $id_lang integer - Language ID
  • $p integer - Page number
  • $n integer - Number of products per page
  • $order_by mixed
  • $order_way mixed
  • $get_total boolean - return the number of results instead of the results themself
  • $active boolean - return only active products
  • $random boolean - active a random filter for returned products
  • $random_number_products integer - number of products to return if random is activated
  • $check_access boolean - set to false to return all products (even if customer hasn't access)
  • $context Context

getProductsWs

mixed CategoryCore::getProductsWs()

getRootCategory

mixed CategoryCore::getRootCategory($id_lang, \Shop $shop)

Arguments

  • $id_lang mixed
  • $shop Shop

getSimpleCategories

mixed CategoryCore::getSimpleCategories($id_lang)

Arguments

  • $id_lang mixed

getSubCategories

array CategoryCore::getSubCategories(integer $id_lang, boolean $active)

Return current category childs

Arguments

  • $id_lang integer - Language ID
  • $active boolean - return only active categories

getTranslationsFields

mixed ObjectModelCore::getTranslationsFields($fieldsArray)

Arguments

  • $fieldsArray mixed

getUrlRewriteInformations

mixed CategoryCore::getUrlRewriteInformations($id_category)

Arguments

  • $id_category mixed

getValidationRules

array ObjectModelCore::getValidationRules(string $className)

Returns object validation rules (fields validity)

Arguments

  • $className 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($wsParamsAttributeName)

Arguments

  • $wsParamsAttributeName mixed

getWsNbProductsRecursive

mixed CategoryCore::getWsNbProductsRecursive()

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

inShop

boolean CategoryCore::inShop(\Shop $shop)

Check if current category is a child of shop root category

Arguments

isAssociatedToGroupShop

boolean ObjectModelCore::isAssociatedToGroupShop(integer $id_group_shop)

Check if current object is associated to a group shop

Arguments

  • $id_group_shop 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()

makeTranslationFields

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

Arguments

  • $fields mixed
  • $fieldsArray mixed
  • $id_language mixed

recalculateLevelDepth

mixed CategoryCore::recalculateLevelDepth(integer $id_category)

Updates level_depth for all children of the given id_category

Arguments

  • $id_category integer - parent category

recurseCategory

mixed CategoryCore::recurseCategory($categories, $current, $id_category, $id_selected)

Arguments

  • $categories mixed
  • $current mixed
  • $id_category mixed
  • $id_selected mixed

recurseLiteCategTree

array CategoryCore::recurseLiteCategTree(integer $max_depth, integer $current_depth, integer $id_lang, array $excluded_ids_array)

Recursive scan of subcategories

Arguments

  • $max_depth integer - Maximum depth of the tree (i.e. 2 => 3 levels depth)
  • $current_depth integer - specify the current depth in the tree (don't use it, only for rucursivity!)
  • $id_lang integer - Specify the id of the language used
  • $excluded_ids_array array - specify a list of ids to exclude of results

recursiveDelete

mixed CategoryCore::recursiveDelete($to_delete, array $id_category)

Recursively add specified category childs to $to_delete array

Arguments

  • $to_delete mixed
  • $id_category array - Parent category ID

regenerateEntireNtree

mixed CategoryCore::regenerateEntireNtree()

Re-calculate the values of all branches of the nested tree

save

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

Save current object to database (add or update)

Arguments

  • $null_values boolean
  • $autodate boolean

searchByName

array CategoryCore::searchByName(integer $id_lang, string $query, boolean $unrestricted)

Light back office search for categories

Arguments

  • $id_lang integer - Language ID
  • $query string - Searched string
  • $unrestricted boolean - allows search without lang and includes first category and exact match

searchByNameAndParentCategoryId

array CategoryCore::searchByNameAndParentCategoryId(integer $id_lang, string $category_name, integer $id_parent_category)

Retrieve category by name and parent category id

Arguments

  • $id_lang integer - Language ID
  • $category_name string - Searched category name
  • $id_parent_category integer - parent category ID

setDefinitionRetrocompatibility

mixed ObjectModelCore::setDefinitionRetrocompatibility()

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

setNewGroupForHome

mixed CategoryCore::setNewGroupForHome($id_group)

Arguments

  • $id_group mixed

toggleStatus

mixed CategoryCore::toggleStatus()

update

void CategoryCore::update(mixed $nullValues)

update category positions in parent

Arguments

  • $nullValues mixed

updateGroup

mixed CategoryCore::updateGroup(array $list)

Update customer groups associated to the object

Arguments

  • $list array - groups

updatePosition

mixed CategoryCore::updatePosition($way, $position)

Arguments

  • $way mixed
  • $position mixed

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)

Validate a single field

Arguments

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

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