Documentation

ShopCategory
in package

Container for Products in the Shop.

Tags
copyright

CLOUDREXX CMS - CLOUDREXX AG

author

Reto Kohli reto.kohli@comvation.com

access

public

version
3.0.0
subpackage

module_shop

Table of Contents

Constants

TEXT_DESCRIPTION  = 'category_description'
TEXT_NAME  = 'category_name'
Text keys
TEXT_SHORT_DESCRIPTION  = 'category_short_description'

Properties

$shortDescription  : string
$active  : bool
$description  : string
$flags  : string
$id  : int
$name  : string
$ord  : int
$parent_id  : int
$picture  : string

Methods

__construct()  : ShopCategory
Create a ShopCategory
active()  : bool
Sets the active status, if present, and returns the current value
addFlag()  : bool
Adds a flag
delete()  : bool
Deletes this ShopCategory from the database.
deleteChildNamed()  : bool
Looks for and deletes the sub-ShopCategory named $name contained by the ShopCategory specified by $parent_id.
description()  : string
Sets the description, if present, and returns the current value
errorHandler()  : bool
Handles any kind of database error
flags()  : string
Sets the flags, if present, and returns the current value
getById()  : ShopCategory
Returns a ShopCategory selected by its ID from the database.
getCategoryTree()  : array<string|int, mixed>
Returns an array representing a tree of ShopCategories, not including the root chosen.
getChildCategories()  : mixed
Returns an array of this ShopCategory's children from the database.
getChildNamed()  : mixed
Returns the child ShopCategory of this with the given name, if found.
getChildrenIdArray()  : mixed
Returns an array of all IDs of children ShopCateries.
getNextShopCategoryId()  : int
Returns the ShopCategory ID following $shopCategoryId according to the sorting order.
getParentCategoryId()  : int
Returns the parent category ID, or 0 (zero)
getShopCategoryMenuHierarchic()  : string
Returns the HTML code for a dropdown menu listing all ShopCategories.
getShopCategoryMenuHierarchicRecurse()  : string
Builds the ShopCategory menu recursively.
id()  : int
Returns the ShopCategory ID
insert()  : bool
Inserts this ShopCategory into the database.
makeClone()  : void
Clones the ShopCategory
name()  : string
Sets the name, if present, and returns the current value
ord()  : int
Sets the ordinal, if present, and returns the current value
parent_id()  : int
Sets the parent ID, if present, and returns the current value.
picture()  : string
Sets the picture file name, if present, and returns the current value
recordExists()  : bool
Tests whether a record with the ID of this object is already present in the database.
removeFlag()  : bool
Removes a flag
shortDescription()  : string
Sets the short description, if present, and returns the current value
store()  : bool
Stores the ShopCategory object in the database.
testFlag()  : bool
Tests for a match with the ShopCategory flags.
testFlag2()  : bool
Tests for a match with the flags in the string.
update()  : bool
Updates this ShopCategory in the database.
virtual()  : bool
Sets the virtual flag if the argument evaluates to any boolean value, and returns the current state

Constants

TEXT_SHORT_DESCRIPTION

public mixed TEXT_SHORT_DESCRIPTION = 'category_short_description'

Properties

$shortDescription

protected string $shortDescription = ''

ShopCategory short description

$active

private bool $active = 1

Active status of the ShopCategory

Tags
access

private

$description

private string $description = ''

ShopCategory description

Tags
access

private

$parent_id

private int $parent_id = 0

Parent ShopCategory ID

Tags
access

private

$picture

private string $picture = ''

ShopCategory picture name

Tags
access

private

Methods

__construct()

Create a ShopCategory

public __construct(string $name[, string $shortDescription = null ][, string $description = null ][, int $parent_id = 0 ][, int $active = null ][, int $ord = 0 ][, int $id = 0 ]) : ShopCategory

If the optional argument $category_id is greater than zero, the corresponding category is updated. Otherwise, a new category is created.

Parameters
$name : string

The category name

$shortDescription : string = null

The optional category short description

$description : string = null

The optional category description

$parent_id : int = 0

The optional parent ID of the category

$active : int = null

The optional active status category. Defaults to null (unset)

$ord : int = 0

The optional ordinal value

$id : int = 0

The optional category ID

Tags
access

public

author

Reto Kohli reto.kohli@comvation.com

Return values
ShopCategory

The ShopCategory

active()

Sets the active status, if present, and returns the current value

public active([bool $active = null ]) : bool
Parameters
$active : bool = null

The optional active status

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
bool

The active status

addFlag()

Adds a flag

public addFlag(string $flag) : bool

Note that the match is case insensitive.

Parameters
$flag : string

The flag to be added

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
bool

Boolean true if the flags were accepted or already present, false otherwise (always true for the time being).

delete()

Deletes this ShopCategory from the database.

public delete([mixed $flagDeleteImages = false ]) : bool

Also removes associated subcategories and Products. Images will only be erased from the disc if the optional $flagDeleteImages parameter evaluates to true.

Parameters
$flagDeleteImages : mixed = false
Tags
global

ADONewConnection $objDatabase Database connection object

author

Reto Kohli reto.kohli@comvation.com

Return values
bool

True on success, false otherwise

deleteChildNamed()

Looks for and deletes the sub-ShopCategory named $name contained by the ShopCategory specified by $parent_id.

public static deleteChildNamed(mixed $parent_id, string $name) : bool

The child's name must be unambiguous, or the method will fail.

Parameters
$parent_id : mixed
$name : string

The ShopCategory name to delete

Tags
author

Reto Kohli reto.kohli@comvation.com

static
Return values
bool

True on success, false otherwise

description()

Sets the description, if present, and returns the current value

public description([string $description = null ]) : string
Parameters
$description : string = null

The optional description

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The current description

errorHandler()

Handles any kind of database error

public static errorHandler() : bool
Tags
throws
Update_DatabaseException
Return values
bool

False. Always.

flags()

Sets the flags, if present, and returns the current value

public flags([string $flags = null ]) : string
Parameters
$flags : string = null

The optional flags

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The current flags

getById()

Returns a ShopCategory selected by its ID from the database.

public static getById(int $category_id[, int $localeId = 0 ]) : ShopCategory

Returns null if the Category does not exist.

Parameters
$category_id : int

The Shop Category ID

$localeId : int = 0

Optional locale ID. If not set FRONTEND_LANG_ID will be used.

Tags
static
global

ADONewConnection $objDatabase Database connection object

author

Reto Kohli reto.kohli@comvation.com

Return values
ShopCategory

The Shop Category object on success, false on failure, or null otherwise.

getCategoryTree()

Returns an array representing a tree of ShopCategories, not including the root chosen.

public static getCategoryTree([int $parent_id = 0 ][, bool $active = false ][, int $level = 0 ]) : array<string|int, mixed>

The resulting array looks like: array( parent ID => array( child ID => array( 'ord' => val, 'active' => val, 'level' => val, ), ... more children ), ... more parents )

Parameters
$parent_id : int = 0

The optional root ShopCategory ID. Defaults to 0 (zero).

$active : bool = false

Only return ShopCategories with active==1 if true. Defaults to false.

$level : int = 0

Optional nesting level, initially 0. Defaults to 0 (zero).

Tags
static
Return values
array<string|int, mixed>

The array of ShopCategories, or false on failure.

getChildCategories()

Returns an array of this ShopCategory's children from the database.

public getChildCategories([bool $active = false ]) : mixed
Parameters
$active : bool = false

Only return ShopCategories with active==1 if true. Defaults to false.

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
mixed

An array of ShopCategory objects on success, false otherwise

getChildNamed()

Returns the child ShopCategory of this with the given name, if found.

public static getChildNamed(string $strName[, bool $active = true ]) : mixed

Returns false if the query fails, or if no child ShopCategory of that name can be found. //Note that if there are two or more children of the same name (and with //active status, if $active is true), a warning will be echo()ed. //This is by design.

Parameters
$strName : string

The child ShopCategory name

$active : bool = true

If true, only active ShopCategories are considered.

Tags
static
global

ADONewConnection $objDatabase Database connection object

global

array

author

Reto Kohli reto.kohli@comvation.com

Return values
mixed

The ShopCategory on success, false otherwise.

getChildrenIdArray()

Returns an array of all IDs of children ShopCateries.

public getChildrenIdArray() : mixed
Tags
global

ADONewConnection $objDatabase Database connection object

author

Reto Kohli reto.kohli@comvation.com

Return values
mixed

Array of the resulting Shop Category IDs on success, false otherwise

getNextShopCategoryId()

Returns the ShopCategory ID following $shopCategoryId according to the sorting order.

public static getNextShopCategoryId([int $shopCategoryId = 0 ]) : int
Parameters
$shopCategoryId : int = 0

The ShopCategory ID

Tags
author

Reto Kohli reto.kohli@comvation.com

static
Return values
int

The next ShopCategory ID

getParentCategoryId()

Returns the parent category ID, or 0 (zero)

public static getParentCategoryId(int $intCategoryId) : int

If the ID given corresponds to a top level category, 0 (zero) is returned, as there is no parent. If the ID cannot be found, 0 (zero) is returned as well.

Parameters
$intCategoryId : int

The category ID

Tags
author

Reto Kohli reto.kohli@comvation.com

global

ADONewConnection $objDatabase Database connection object

static
Return values
int

The parent category ID, or 0 (zero) on failure.

getShopCategoryMenuHierarchic()

Returns the HTML code for a dropdown menu listing all ShopCategories.

public static getShopCategoryMenuHierarchic([mixed $selected = 0 ][, string $name = 'catId' ]) : string

If the optional menu name string is non-empty, the