\CategoryCore

Summary

Methods
Properties
Constants
__construct()
getDescriptionClean()
add()
update()
toggleStatus()
recurseLiteCategTree()
recurseCategory()
deleteLite()
delete()
deleteSelection()
calcLevelDepth()
regenerateEntireNtree()
recalculateLevelDepth()
getCategories()
getNestedCategories()
getSimpleCategories()
getShopID()
getSubCategories()
getProducts()
getHomeCategories()
getRootCategory()
getChildren()
getAllChildren()
getAllParents()
getChildrenWithNbSelectedSubCat()
duplicateProductCategories()
checkBeforeMove()
getLinkRewrite()
getLink()
getName()
searchByName()
searchByNameAndParentCategoryId()
searchByPath()
getParentsCategories()
categoryExists()
cleanGroups()
cleanAssoProducts()
addGroups()
getGroups()
addGroupsIfNoExist()
checkAccess()
updateGroup()
setNewGroupForHome()
updatePosition()
cleanPositions()
getLastPosition()
getUrlRewriteInformations()
getInterval()
inShop()
inShopStatic()
getChildrenWs()
getProductsWs()
getDuplicatePosition()
getWsNbProductsRecursive()
getCategoryInformations()
isParentCategoryAvailable()
addShop()
getRootCategories()
getCategoriesWithoutParent()
isRootCategoryForAShop()
getTopCategory()
addPosition()
getShopsByCategory()
updateFromShop()
deleteFromShop()
deleteCategoriesFromShop()
addToShop()
existsInShop()
$id
$id_category
$name
$active
$position
$description
$id_parent
$id_category_default
$level_depth
$nleft
$nright
$link_rewrite
$meta_title
$meta_keywords
$meta_description
$date_add
$date_upd
$is_root_category
$id_shop_default
$groupBox
$definition
$id_image
No constants found
recursiveDelete()
_subTree()
$_links
$webserviceParameters
N/A
No private methods found
No private properties found
N/A

Properties

$id

$id : 

Type

$id_category

$id_category : integer

Type

integer — category ID

$name

$name : string

Type

string — Name

$active

$active : boolean

Type

boolean — Status for display

$position

$position : integer

Type

integer — category position

$description

$description : string

Type

string — Description

$id_parent

$id_parent : integer

Type

integer — Parent category ID

$id_category_default

$id_category_default : integer

Type

integer — default Category id

$level_depth

$level_depth : integer

Type

integer — Parents number

$nleft

$nleft : integer

Type

integer — Nested tree model "left" value

$nright

$nright : integer

Type

integer — Nested tree model "right" value

$link_rewrite

$link_rewrite : string

Type

string — string used in rewrited URL

$meta_title

$meta_title : string

Type

string — Meta title

$meta_keywords

$meta_keywords : string

Type

string — Meta keywords

$meta_description

$meta_description : string

Type

string — Meta description

$date_add

$date_add : string

Type

string — Object creation date

$date_upd

$date_upd : string

Type

string — Object last modification date

$is_root_category

$is_root_category : boolean

Type

boolean — is Category Root

$id_shop_default

$id_shop_default : integer

Type

integer

$groupBox

$groupBox : 

Type

$definition

$definition : 

Type

$id_image

$id_image : string

Type

string — id_image is the category ID when an image exists and 'default' otherwise

$_links

$_links : 

Type

$webserviceParameters

$webserviceParameters : 

Type

Methods

__construct()

__construct(  $id_category = null,   $id_lang = null,   $id_shop = null) 

Parameters

$id_category
$id_lang
$id_shop

getDescriptionClean()

getDescriptionClean(  $description) 

Parameters

$description

add()

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

Parameters

$autodate
$null_values

update()

update(mixed  $null_values = false) : boolean

update category positions in parent

Parameters

mixed $null_values

Returns

boolean

toggleStatus()

toggleStatus() 

recurseLiteCategTree()

recurseLiteCategTree(integer  $max_depth = 3, integer  $current_depth, integer  $id_lang = null, array  $excluded_ids_array = null) : array

Recursive scan of subcategories

Parameters

integer $max_depth

Maximum depth of the tree (i.e. 2 => 3 levels depth)

integer $current_depth

specify the current depth in the tree (don't use it, only for rucursivity!)

integer $id_lang

Specify the id of the language used

array $excluded_ids_array

specify a list of ids to exclude of results

Returns

array —

Subcategories lite tree

recurseCategory()

recurseCategory(  $categories,   $current,   $id_category = null,   $id_selected = 1) 

Parameters

$categories
$current
$id_category
$id_selected

deleteLite()

deleteLite() 

delete()

delete() 

deleteSelection()

deleteSelection(  $categories) 

Delete several categories from database

return boolean Deletion result

Parameters

$categories

calcLevelDepth()

calcLevelDepth() : integer

Get the depth level for the category

Returns

integer —

Depth level

regenerateEntireNtree()

regenerateEntireNtree() 

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

recalculateLevelDepth()

recalculateLevelDepth(integer  $id_category) 

Updates level_depth for all children of the given id_category

Parameters

integer $id_category

parent category

getCategories()

getCategories(integer  $id_lang = false, boolean  $active = true,   $order = true,   $sql_filter = '',   $sql_sort = '',   $sql_limit = '') : array

Return available categories

Parameters

integer $id_lang

Language ID

boolean $active

return only active categories

$order
$sql_filter
$sql_sort
$sql_limit

Returns

array —

Categories

getNestedCategories()

getNestedCategories(  $root_category = null,   $id_lang = false,   $active = true,   $groups = null,   $use_shop_restriction = true,   $sql_filter = '',   $sql_sort = '',   $sql_limit = '') 

Parameters

$root_category
$id_lang
$active
$groups
$use_shop_restriction
$sql_filter
$sql_sort
$sql_limit

getSimpleCategories()

getSimpleCategories(  $id_lang) 

Parameters

$id_lang

getShopID()

getShopID() 

getSubCategories()

getSubCategories(integer  $id_lang, boolean  $active = true) : array

Return current category childs

Parameters

integer $id_lang

Language ID

boolean $active

return only active categories

Returns

array —

Categories

getProducts()

getProducts(integer  $id_lang, integer  $p, integer  $n,   $order_by = null,   $order_way = null, boolean  $get_total = false, boolean  $active = true, boolean  $random = false, integer  $random_number_products = 1, boolean  $check_access = true, \Context  $context = null) : mixed

Return current category products

Parameters

integer $id_lang

Language ID

integer $p

Page number

integer $n

Number of products per page

$order_by
$order_way
boolean $get_total

return the number of results instead of the results themself

boolean $active

return only active products

boolean $random

active a random filter for returned products

integer $random_number_products

number of products to return if random is activated

boolean $check_access

set to false to return all products (even if customer hasn't access)

\Context $context

Returns

mixed —

Products or number of products

getHomeCategories()

getHomeCategories(integer  $id_lang, boolean  $active = true,   $id_shop = false) : array

Return main categories

Parameters

integer $id_lang

Language ID

boolean $active

return only active categories

$id_shop

Returns

array —

categories

getRootCategory()

getRootCategory(  $id_lang = null, \Shop  $shop = null) 

Parameters

$id_lang
\Shop $shop

getChildren()

getChildren(integer  $id_parent, integer  $id_lang, boolean  $active = true,   $id_shop = false) : array

Parameters

integer $id_parent
integer $id_lang
boolean $active
$id_shop

Returns

array

getAllChildren()

getAllChildren(integer  $id_lang = null) : \PrestaShopCollection

Return an array of all children of the current category

Parameters

integer $id_lang

Returns

\PrestaShopCollection —

Collection of Category

getAllParents()

getAllParents(integer  $id_lang = null) : \PrestaShopCollection

Return an array of all parents of the current category

Parameters

integer $id_lang

Returns

\PrestaShopCollection —

Collection of Category

getChildrenWithNbSelectedSubCat()

getChildrenWithNbSelectedSubCat(integer  $id_parent,   $selected_cat, integer  $id_lang, \Shop  $shop = null,   $use_shop_context = true) : array

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

Parameters

integer $id_parent
$selected_cat
integer $id_lang
\Shop $shop
$use_shop_context

Returns

array

duplicateProductCategories()

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

Copy products from a category to another

Parameters

integer $id_old

Source category ID

boolean $id_new

Destination category ID

Returns

boolean —

Duplication result

checkBeforeMove()

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

Check if category can be moved in another one.

The category cannot be moved in a child category.

Parameters

integer $id_category

current category

integer $id_parent

Parent candidate

Returns

boolean —

Parent validity

getLinkRewrite()

getLinkRewrite(  $id_category,   $id_lang) 

Parameters

$id_category
$id_lang

getLink()

getLink(\Link  $link = null,   $id_lang = null) 

Parameters

\Link $link
$id_lang

getName()

getName(  $id_lang = null) 

Parameters

$id_lang

searchByName()

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

Light back office search for categories

Parameters

integer $id_lang

Language ID

string $query

Searched string

boolean $unrestricted

allows search without lang and includes first category and exact match

Returns

array —

Corresponding categories

searchByNameAndParentCategoryId()

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

Retrieve category by name and parent category id

Parameters

integer $id_lang

Language ID

string $category_name

Searched category name

integer $id_parent_category

parent category ID

Returns

array —

Corresponding category

searchByPath()

searchByPath(integer  $id_lang, string  $path, boolean  $object_to_create = false,   $method_to_create = false) : array

Search with Pathes for categories

Parameters

integer $id_lang

Language ID

string $path

of category

boolean $object_to_create

a category

  • @param boolean $method_to_create a category
$method_to_create

Returns

array —

Corresponding categories

getParentsCategories()

getParentsCategories(integer  $id_lang = null) : array

Get Each parent category of this category until the root category

Parameters

integer $id_lang

Language ID

Returns

array —

Corresponding categories

categoryExists()

categoryExists(integer  $id_category) : boolean

Specify if a category already in base

Parameters

integer $id_category

Category id

Returns

boolean

cleanGroups()

cleanGroups() 

cleanAssoProducts()

cleanAssoProducts() 

addGroups()

addGroups(  $groups) 

Parameters

$groups

getGroups()

getGroups() 

addGroupsIfNoExist()

addGroupsIfNoExist(  $id_group) 

Parameters

$id_group

checkAccess()

checkAccess(mixed  $id_customer) : boolean

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

Parameters

mixed $id_customer

Returns

boolean —

true if access allowed for customer $id_customer

updateGroup()

updateGroup(array  $list) 

Update customer groups associated to the object

Parameters

array $list

groups

setNewGroupForHome()

setNewGroupForHome(  $id_group) 

Parameters

$id_group

updatePosition()

updatePosition(  $way,   $position) 

Parameters

$way
$position

cleanPositions()

cleanPositions(mixed  $id_category_parent = null) : boolean

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

Parameters

mixed $id_category_parent

Returns

boolean —

true if succeed

getLastPosition()

getLastPosition(integer  $id_category_parent, integer  $id_shop) : integer

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

Parameters

integer $id_category_parent

the parent category

integer $id_shop

Returns

integer

getUrlRewriteInformations()

getUrlRewriteInformations(  $id_category) 

Parameters

$id_category

getInterval()

getInterval(integer  $id) : array

Return nleft and nright fields for a given category

Parameters

integer $id

Returns

array

inShop()

inShop(\Shop  $shop = null) : boolean

Check if current category is a child of shop root category

Parameters

\Shop $shop

Returns

boolean

inShopStatic()

inShopStatic(  $id_category, \Shop  $shop = null) 

Parameters

$id_category
\Shop $shop

getChildrenWs()

getChildrenWs() 

getProductsWs()

getProductsWs() 

getDuplicatePosition()

getDuplicatePosition() : array

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

Returns

array —

first category found

getWsNbProductsRecursive()

getWsNbProductsRecursive() 

getCategoryInformations()

getCategoryInformations(Array  $ids_category, integer  $id_lang = null) : Array

Parameters

Array $ids_category
integer $id_lang

Returns

Array

isParentCategoryAvailable()

isParentCategoryAvailable(  $id_shop) : boolean

Parameters

$id_shop

Returns

boolean

addShop()

addShop(integer  $id_shop) : boolean

Add association between shop and categories

Parameters

integer $id_shop

Returns

boolean

getRootCategories()

getRootCategories(  $id_lang = null,   $active = true) 

Parameters

$id_lang
$active

getCategoriesWithoutParent()

getCategoriesWithoutParent() 

isRootCategoryForAShop()

isRootCategoryForAShop() 

getTopCategory()

getTopCategory(null  $id_lang = null) : \Category

Parameters

null $id_lang

Returns

\Category

addPosition()

addPosition(  $position,   $id_shop = null) 

Parameters

$position
$id_shop

getShopsByCategory()

getShopsByCategory(  $id_category) 

Parameters

$id_category

updateFromShop()

updateFromShop(string  $categories, string  $id_shop) : array

Update categories for a shop

Parameters

string $categories

Categories list to associate a shop

string $id_shop

Categories list to associate a shop

Returns

array —

Update/insertion result

deleteFromShop()

deleteFromShop(integer  $id_shop) : boolean

Delete category from shop $id_shop

Parameters

integer $id_shop

Returns

boolean

deleteCategoriesFromShop()

deleteCategoriesFromShop(  $id_shop) : boolean

Delete every categories

Parameters

$id_shop

Returns

boolean

addToShop()

addToShop(array  $categories,   $id_shop) : boolean

Add some categories to a shop

Parameters

array $categories
$id_shop

Returns

boolean

existsInShop()

existsInShop(  $id_shop) 

Parameters

$id_shop

recursiveDelete()

recursiveDelete(  $to_delete, integer  $id_category) 

Recursively add specified category childs to $to_delete array

Parameters

$to_delete
integer $id_category

Parent category ID

_subTree()

_subTree(  $categories,   $id_category,   $n) 

Parameters

$categories
$id_category
$n