ProductListProvider
extends AbstractDataPaginator
in package
implements
ProductListProviderInterface
Class ProductListProvider
Tags
Interfaces, Classes and Traits
- ProductListProviderInterface
- Interface ProductListProviderInterface
Table of Contents
- $fieldMap : mixed
- Maps the entity Fields with the database fields
- $conditions : array<string|int, mixed>
- Database query conditions.
- $db : mixed
- $languageCode : LanguageCode
- Two-letter language code.
- $productRepository : ProductRepositoryInterface
- Product repository.
- __construct() : mixed
- ProductListProvider constructor.
- _translateOrderByStringIntoArrayOfSorter() : array<string|int, mixed>
- Translate an order by sql instruction into a array of Sorter
- getAll() : ProductListItemCollection
- Get all product list items.
- getAllPaged() : ProductListItemCollection
- Returns a paged list of product items.
- getByCategoryId() : ProductListItemCollection
- Returns a product list item collection by the provided category ID.
- searchProducts() : ProductListItemCollection
- Filters products records by a given ProductSearchCondition object and returns an collection with results.
- searchProductsCount() : IntType
- Count the total of filtered products.
- _applyDefaultSorting() : mixed
- Applies the class default sorting
- _applyExtraConditions() : ProductListProvider
- Apply extra query conditions.
- _applyPagination() : $this|ProductListProvider
- Applies a pagination (Limit and Offset) clause to the currently building query.
- _applySorting() : $this|ProductListProvider
- Applies a sorting based on sorter param (if sorting is supplied) or apply default sorting.
- _getFieldMap() : mixed
- return the child class Field Map array.
- _parseOrderByString() : array<string|int, mixed>
- Parse an order by sql query into a array with fieldname and direction.
- _prepareCollection() : ProductListItemCollection
- Prepares the ProductListItemCollection object.
- _select() : ProductListProvider
- Build the select part of the query build.
- _selectWithCategories() : ProductListProvider
- Build the select part of the query build and additionally join the products_to_categories table.
- _translateToDatabaseField() : mixed
- Return the related database field of a given object(Entity) field.
- _translateToJsonFieldName() : string|false
- Parse an order by sql query into a array with fieldname and direction.
Properties
$fieldMap
Maps the entity Fields with the database fields
public
static mixed
$fieldMap
= ['id' => 'products.products_id', 'isactive' => 'products_status', 'sortorder' => 'products_sort', 'dateadded' => 'products_date_added', 'dateavailable' => 'products_date_available', 'lastmodified' => 'products_last_modified', 'orderedcount' => 'products_ordered', 'productmodel' => 'products_model', 'ean' => 'products_ean', 'price' => 'products_price', 'discountallowed' => 'products_discount_allowed', 'taxclassid' => 'products_tax_class_id', 'quantity' => 'products_quantity', 'name' => 'products_name', 'image' => 'products_image', 'imagealttext' => 'gm_alt_text', 'urlkeywords' => 'products_meta_keywords', 'weight' => 'products_weight', 'shippingcosts' => 'nc_ultra_shipping_costs', 'shippingtimeid' => 'products_shippingtime', 'producttypeid' => 'product_type', 'manufacturerid' => 'manufacturers_id', 'quantityunitid' => 'quantity_unit_id', 'isfsk18' => 'products_fsk18', 'isvpeactive' => 'products_vpe_status', 'vpeid' => 'products_vpe', 'vpevalue' => 'products_vpe_value', 'specialofferid' => 'specials_id', 'maincategoryid' => 'main_category_id']
$conditions
Database query conditions.
protected
array<string|int, mixed>
$conditions
$db
protected
mixed
$db
$languageCode
Two-letter language code.
protected
LanguageCode
$languageCode
$productRepository
Product repository.
protected
ProductRepositoryInterface
$productRepository
Methods
__construct()
ProductListProvider constructor.
public
__construct(LanguageCode $languageCode, ProductRepositoryInterface $productRepo, CI_DB_query_builder $db[, array<string|int, mixed> $conditions = [] ]) : mixed
Parameters
- $languageCode : LanguageCode
-
Two-letter language code.
- $productRepo : ProductRepositoryInterface
-
Product repository.
- $db : CI_DB_query_builder
-
Database connection.
- $conditions : array<string|int, mixed> = []
-
Database query conditions.
Return values
mixed —_translateOrderByStringIntoArrayOfSorter()
Translate an order by sql instruction into a array of Sorter
public
_translateOrderByStringIntoArrayOfSorter([StringType|null $orderBy = null ]) : array<string|int, mixed>
Parameters
- $orderBy : StringType|null = null
-
SQL instruction with fields to sort.
Return values
array<string|int, mixed> —of Sorter objects.
getAll()
Get all product list items.
public
getAll() : ProductListItemCollection
Return values
ProductListItemCollection —getAllPaged()
Returns a paged list of product items.
public
getAllPaged([Pager|null $pager = null ][, array<string|int, mixed> $sorters = [] ]) : ProductListItemCollection
Parameters
- $pager : Pager|null = null
-
(Optional) Pager object with pagination information
- $sorters : array<string|int, mixed> = []
-
(Optional) array of Sorter objects with data sorting information
Return values
ProductListItemCollection —getByCategoryId()
Returns a product list item collection by the provided category ID.
public
getByCategoryId(IdType $categoryId) : ProductListItemCollection
Parameters
- $categoryId : IdType
-
Category ID.
Tags
Return values
ProductListItemCollection —searchProducts()
Filters products records by a given ProductSearchCondition object and returns an collection with results.
public
searchProducts(ProductSearchCondition $condition[, Pager|null $pager = null ][, array<string|int, mixed> $sorters = [] ]) : ProductListItemCollection
Parameters
- $condition : ProductSearchCondition
-
Conditions object for search.
- $pager : Pager|null = null
-
(Optional) Pager object with pagination information
- $sorters : array<string|int, mixed> = []
-
(Optional) array of Sorter objects with data sorting information
Return values
ProductListItemCollection —searchProductsCount()
Count the total of filtered products.
public
searchProductsCount(ProductSearchCondition $condition) : IntType
Parameters
- $condition : ProductSearchCondition
-
Conditions object for search.
Return values
IntType —_applyDefaultSorting()
Applies the class default sorting
protected
_applyDefaultSorting() : mixed
Return values
mixed —_applyExtraConditions()
Apply extra query conditions.
protected
_applyExtraConditions() : ProductListProvider
Return values
ProductListProvider —Same instance for chained method calls.
_applyPagination()
Applies a pagination (Limit and Offset) clause to the currently building query.
protected
_applyPagination([Pager|null $pager = null ]) : $this|ProductListProvider
Parameters
- $pager : Pager|null = null
-
(Optional) Pager object with pagination information
Return values
$this|ProductListProvider —Same instance for chained method calls.
_applySorting()
Applies a sorting based on sorter param (if sorting is supplied) or apply default sorting.
protected
_applySorting([array<string|int, mixed> $sorters = [] ]) : $this|ProductListProvider
Parameters
- $sorters : array<string|int, mixed> = []
-
Array of Sorter objects.
Tags
Return values
$this|ProductListProvider —Same instance for chained method calls.
_getFieldMap()
return the child class Field Map array.
protected
_getFieldMap() : mixed
Return values
mixed —_parseOrderByString()
Parse an order by sql query into a array with fieldname and direction.
protected
_parseOrderByString([StringType|null $orderBy = null ]) : array<string|int, mixed>
Parameters
- $orderBy : StringType|null = null
-
SQL order by String
Return values
array<string|int, mixed> —with sort information structured as ['field'=>'', 'direction'=>''].
_prepareCollection()
Prepares the ProductListItemCollection object.
protected
_prepareCollection(array<string|int, mixed> $result) : ProductListItemCollection
Parameters
- $result : array<string|int, mixed>
-
Query result.
Tags
Return values
ProductListItemCollection —_select()
Build the select part of the query build.
protected
_select() : ProductListProvider
Return values
ProductListProvider —Same instance for chained method calls.
_selectWithCategories()
Build the select part of the query build and additionally join the products_to_categories table.
protected
_selectWithCategories() : ProductListProvider
Return values
ProductListProvider —Same instance for chained method calls.
_translateToDatabaseField()
Return the related database field of a given object(Entity) field.
protected
_translateToDatabaseField(string $fieldName) : mixed
Parameters
- $fieldName : string
-
Object Field name.
Tags
Return values
mixed —_translateToJsonFieldName()
Parse an order by sql query into a array with fieldname and direction.
protected
_translateToJsonFieldName(StringType $databaseFieldName) : string|false
Parameters
- $databaseFieldName : StringType
-
the database field name. It can be supplied as table.fieldName or fieldName.
Return values
string|false —will return the field name or FALSE if the field doesn't exist.