Cart Boxx – Catalog Library Reference

THE CLASS ITSELF

class Catalog

Description: A massive library dealing with the catalog – Products, categories, and assigning products to categories.
File: cart-boxx/core/lib/LIB_Catalog.php

Example Usage
$_CB->extend(“Catalog”);
$category = $_CB->Catalog->getCat(8);

 

CATEGORY RELATED

function catCount

Description: Count the total number of categories.

Parameters
[STRING] $search – Optional, search for this category name.
Return
[INT] Total number of categories
function getAllCat

Description: Get all categories.

Parameters
[STRING] $search – Optional, search for this category name.
[INT] $page – Optional, the current page number, will automatically LIMIT the results based on the PER_PAGE setting in the config database.
Return
[ARRAY] The categories
[BOOL] False if no results are found
function getCat

Description: Get category by category ID.

Parameters
[INT] $id – Category ID
Return
[ARRAY] The category
[BOOL] False if no results are found
function getCatSlug

Description: Get category by URL slug.

Parameters
[STRING] $slug – The URL Slug
[INT] $excl – (Optional) Exclude this category ID from the search, see checkCatSlug below.
Return
[INT] Total number of categories
function checkCatSlug

Description: Check if the given slug is already in use.

Parameters
[STRING] $slug – The URL Slug
[INT] $excl – (Optional) Exclude this category ID from the search. If you update a category and do not change the slug – The system will give a false ‘already registered’ if you do not exclude the updating category.
Return
[BOOL] True if already registered, false if not.
function addCat

Description: Add a new category.

Parameters
[ARRAY] $cat – Category data, as with the fields in the category table in the database.
Return
[BOOL] True on pass, false on fail
function editCat

Description: Update category.

Parameters
[ARRAY] $cat – Category data, as with the fields in the category table in the database.
Return
[BOOL] True on pass, false on fail
function delCat

Description: Delete a category

Parameters
[INT] $id – Category ID to delete.
Return
[BOOL] True on pass, false on fail

 

PRODUCT RELATED

function pdtCount

Description: Count the number of products

Parameters
[STRING] $search – Optional, search for this product name.
Return
[INT] Number of products
function getAllPdt

Description: Get all products.

Parameters
[STRING] $search – Optional, search for this product name.
[INT] $page – Optional, the current page number, will automatically LIMIT the results based on the PER_PAGE setting in the config database.
[INT] $cat – Optional, category ID. Will attach a category ID field in the results. If set, product is assigned to the specified category. Used to quickly determine if certain products are in the specified category.
Return
[ARRAY] Products
function getPdtCat

Description: Get products in category

Parameters
[INT] $id – Category ID
Return
[ARRAY] Products
[BOOL] False if no products are found in category
function getPdt

Description: Get product by ID

Parameters
[INT] $id – Product ID
Return
[ARRAY] Product
[BOOL] False if give product ID is not found
function addPdt

Description: Add product.

Parameters
[ARRAY] $pdt – Product data, as with the fields in the product table in the database.
Return
[BOOL] True on success, false on fail
function editPdt

Description: Update product

Parameters
[ARRAY] $pdt – Product data, as with the fields in the product table in the database.
Return
[BOOL] True on success, false on fail
function delPdt

Description: Delete product

Parameters
[INT] Product ID
Return
[BOOL] True on success, false on fail

 

ASSIGNMENT RELATED

function pdtAddCat

Description: Assign products to categories

Parameters
[ARRAY] $data – Array of {PRODUCT ID:[CATEGORY IDS], PRODUCT ID:[CATEGORY IDS]}
Example
If I want to add product ID 1 to category 2 and 3, product ID 4 to category 5 and 6 – [1:[2,3],4:[5,6]]
Return
[BOOL] True on success, false on fail
function pdtDelCat

Description: Remove given products from categories

Parameters
[ARRAY] $data – Array of {PRODUCT ID:[CATEGORY IDS], PRODUCT ID:[CATEGORY IDS]}
Example
If I want to remove product ID 1 from category 2 and 3 – [1:[2,3]]
Return
[BOOL] True on success, false on fail

Leave a Comment

Your email address will not be published. Required fields are marked *