OrderListGenerator
extends AbstractDataPaginator
in package
implements
OrderListGeneratorInterface
Class OrderListGenerator
Tags
Interfaces, Classes and Traits
- OrderListGeneratorInterface
- Interface OrderListGeneratorInterface
Table of Contents
- FILTER_NO_VALUE = '{no-value}'
- $db : CI_DB_query_builder
- $defaultLanguageId : int
- $paymentTitleProvider : PaymentTitleProvider
- $shippingTitleProvider : ShippingTitleProvider
- __construct() : mixed
- OrderListGenerator Constructor
- _translateOrderByStringIntoArrayOfSorter() : array<string|int, mixed>
- Translate an order by sql instruction into a array of Sorter
- filterOrderList() : OrderListItemCollection
- Filter order list items by the provided parameters.
- filterOrderListCount() : int
- Get the filtered orders count.
- getOrderListByConditions() : OrderListItemCollection
- Get Order List Items
- getOrderListByKeyword() : mixed
- Filter records by a single keyword string.
- getOrderListByKeywordCount() : int
- Get count of orders filtered by keyword
- getOrderListCount() : int
- Get the total count of all orders
- _addressColumns() : string
- Returns a string for the ::_select() method which contains column names of the orders table for address data.
- _applyDefaultSorting() : mixed
- Applies the class default sorting
- _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.
- _createInvoiceNumberCollectionByOrderId() : StringCollection
- Creates and returns a string collection which contains the invoice numbers of the order
- _createMemoCollectionByCustomersId() : CustomerMemoCollection
- Creates and returns a customer memo collection by the given customers id.
- _createOrderAddressBlockByRow() : OrderAddressBlock
- Creates an order address block object by the given type and row_array (looped result of CIDB::result_array())
- _createOrderPaymentType() : OrderPaymentType
- Creates and returns an order payment type instance by the given row data.
- _createOrderShippingType() : OrderShippingType
- Creates and returns an order shipping type instance by the given row data.
- _createOrderType() : OrderShippingType|OrderPaymentType
- Creates and returns whether an order shipping or payment type instance by the given row data and type argument.
- _createTrackingLinksByOrderId() : StringCollection
- Creates and returns a string collection which contains the tracking links of the order.
- _createWithdrawalIdsByOrderId() : IdCollection
- Creates and returns a ID collection which contains the withdrawal ids of the order.
- _customersStatusColumns() : string
- Returns a string for the ::_select() method which contains fallback customer status name if no value is set in the orders table.
- _filter() : CI_DB_result
- _filterWithPagerAndSorter() : CI_DB_result
- Filter the order records.
- _getFieldMap() : mixed
- return the child class Field Map array.
- _getPaymentOrShippingTitle() : string
- Returns the title of the given payment or shipping title.
- _group() : OrderListGenerator
- Execute the group by statement.
- _invoicesColumns() : string
- Returns a string for the ::_select() method which contains fallback implosion of all invoice IDs of the order if no value is set in the orders table.
- _order() : OrderListGenerator
- Set the order by clause of the query.
- _ordersColumns() : string
- Returns a string for the ::_select() method which contains column names of the orders table.
- _ordersStatusColumns() : string
- Returns a string for the ::_select() method which contains column names of the orders status table.
- _ordersTotalColumns() : string
- Returns a string for the ::_select() method which contains column names of the orders total table.
- _parseOrderByString() : array<string|int, mixed>
- Parse an order by sql query into a array with fieldname and direction.
- _prepareCollection() : OrderListItemCollection
- Prepare the OrderListItemCollection object.
- _select() : OrderListGenerator
- Execute the select and join methods.
- _setFilterArguments() : OrderListGeneratorInterface
- Set the where clauses for the filtered order records query.
- _setKeywordWhereClause() : mixed
- _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.
- getAllOrderStatuses() : array<string|int, mixed>
- Returns all order statuses using the default language
- getOrderTotalSum() : array<string|int, mixed>
- Returns the total sum for the selected orders
Constants
FILTER_NO_VALUE
public
string
FILTER_NO_VALUE
= '{no-value}'
Properties
$db
protected
CI_DB_query_builder
$db
$defaultLanguageId
protected
int
$defaultLanguageId
$paymentTitleProvider
protected
PaymentTitleProvider
$paymentTitleProvider
$shippingTitleProvider
protected
ShippingTitleProvider
$shippingTitleProvider
Methods
__construct()
OrderListGenerator Constructor
public
__construct(CI_DB_query_builder $db, PaymentTitleProvider $paymentTitleProvider, ShippingTitleProvider $shippingTitleProvider) : mixed
Parameters
- $db : CI_DB_query_builder
- $paymentTitleProvider : PaymentTitleProvider
- $shippingTitleProvider : ShippingTitleProvider
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.
filterOrderList()
Filter order list items by the provided parameters.
public
filterOrderList(array<string|int, mixed> $filterParameters[, Pager|null $pager = null ][, array<string|int, mixed> $sorters = [] ]) : OrderListItemCollection
The following slug names need to be used:
- number => orders.orders_id
- customer => orders.customers_lastname orders.customers_firstname
- group => orders.customers_status_name
- sum => orders_total.value
- payment => orders.payment_method
- shipping => orders.shipping_method
- countryIsoCode => orders.delivery_country_iso_code_2
- date => orders.date_purchased
- status => orders_status.orders_status_name
- totalWeight => orders.order_total_weight
Parameters
- $filterParameters : array<string|int, mixed>
-
Contains the column slug-names and their values.
- $pager : Pager|null = null
-
(Optional) Pager object with pagination information
- $sorters : array<string|int, mixed> = []
-
(Optional) array of Sorter objects with data sorting information
Tags
Return values
OrderListItemCollection —filterOrderListCount()
Get the filtered orders count.
public
filterOrderListCount(array<string|int, mixed> $filterParameters) : int
This number is useful for pagination functionality where the app needs to know the number of the filtered rows.
Parameters
- $filterParameters : array<string|int, mixed>
Tags
Return values
int —getOrderListByConditions()
Get Order List Items
public
getOrderListByConditions([string|array<string|int, mixed> $conditions = [] ][, Pager|null $pager = null ][, array<string|int, mixed> $sorters = [] ]) : OrderListItemCollection
Returns an order list item collection.
Parameters
- $conditions : string|array<string|int, mixed> = []
-
Provide a WHERE clause string or an associative array (actually any parameter that is acceptable by the "where" method of the CI_DB_query_builder method).
- $pager : Pager|null = null
-
(Optional) Pager object with pagination information
- $sorters : array<string|int, mixed> = []
-
(Optional) array of Sorter objects with data sorting information
Tags
Return values
OrderListItemCollection —getOrderListByKeyword()
Filter records by a single keyword string.
public
getOrderListByKeyword(StringType $keyword[, Pager|null $pager = null ][, array<string|int, mixed> $sorters = [] ]) : mixed
Parameters
- $keyword : StringType
-
Keyword string to be used for searching in order records.
- $pager : Pager|null = null
-
(Optional) Pager object with pagination information
- $sorters : array<string|int, mixed> = []
-
(Optional) array of Sorter objects with data sorting information
Tags
Return values
mixed —getOrderListByKeywordCount()
Get count of orders filtered by keyword
public
getOrderListByKeywordCount(StringType $keyword) : int
Parameters
- $keyword : StringType
-
Keyword string to be used for searching in order records.
Return values
int —getOrderListCount()
Get the total count of all orders
public
getOrderListCount() : int
Return values
int —_addressColumns()
Returns a string for the ::_select() method which contains column names of the orders table for address data.
protected
_addressColumns(string $type) : string
Parameters
- $type : string
-
Whether delivery or billing.
Tags
Return values
string —_applyDefaultSorting()
Applies the class default sorting
protected
_applyDefaultSorting() : mixed
Return values
mixed —_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.
_createInvoiceNumberCollectionByOrderId()
Creates and returns a string collection which contains the invoice numbers of the order
protected
_createInvoiceNumberCollectionByOrderId( $orderId) : StringCollection
Parameters
Tags
Return values
StringCollection —_createMemoCollectionByCustomersId()
Creates and returns a customer memo collection by the given customers id.
protected
_createMemoCollectionByCustomersId(int $customersId) : CustomerMemoCollection
Parameters
- $customersId : int
-
Id of customer.
Return values
CustomerMemoCollection —_createOrderAddressBlockByRow()
Creates an order address block object by the given type and row_array (looped result of CIDB::result_array())
protected
_createOrderAddressBlockByRow(string $type, array<string|int, mixed> $row) : OrderAddressBlock
Parameters
- $type : string
-
Whether delivery or billing.
- $row : array<string|int, mixed>
-
Array which contain data about an order result row.
Tags
Return values
OrderAddressBlock —_createOrderPaymentType()
Creates and returns an order payment type instance by the given row data.
protected
_createOrderPaymentType(array<string|int, mixed> $row) : OrderPaymentType
Parameters
- $row : array<string|int, mixed>
-
Row array with data about the order payment type.
Return values
OrderPaymentType —_createOrderShippingType()
Creates and returns an order shipping type instance by the given row data.
protected
_createOrderShippingType(array<string|int, mixed> $row) : OrderShippingType
Parameters
- $row : array<string|int, mixed>
-
Row array with data about the order shipping type.
Return values
OrderShippingType —_createOrderType()
Creates and returns whether an order shipping or payment type instance by the given row data and type argument.
protected
_createOrderType(string $type, array<string|int, mixed> $row) : OrderShippingType|OrderPaymentType
Parameters
- $type : string
-
Whether 'shipping' or 'payment', used to determine the expected order type class.
- $row : array<string|int, mixed>
-
Row array with data about the order type.
Tags
Return values
OrderShippingType|OrderPaymentType —_createTrackingLinksByOrderId()
Creates and returns a string collection which contains the tracking links of the order.
protected
_createTrackingLinksByOrderId(int $orderId) : StringCollection
Parameters
- $orderId : int
-
Id of current order.
Tags
Return values
StringCollection —_createWithdrawalIdsByOrderId()
Creates and returns a ID collection which contains the withdrawal ids of the order.
protected
_createWithdrawalIdsByOrderId(int $orderId) : IdCollection
Parameters
- $orderId : int
-
Id of current order.
Tags
Return values
IdCollection —_customersStatusColumns()
Returns a string for the ::_select() method which contains fallback customer status name if no value is set in the orders table.
protected
_customersStatusColumns() : string
Return values
string —_filter()
protected
_filter(array<string|int, mixed> $filterParameters[, IntType|null $startIndex = null ][, IntType|null $maxCount = null ][, StringType $orderBy = null ]) : CI_DB_result
Parameters
- $filterParameters : array<string|int, mixed>
-
Contains the column slug-names and their values.
- $startIndex : IntType|null = null
-
(Optional) Pager object with pagination information
- $maxCount : IntType|null = null
-
(Optional) array of Sorter objects with data sorting information
- $orderBy : StringType = null
Tags
Return values
CI_DB_result —_filterWithPagerAndSorter()
Filter the order records.
protected
_filterWithPagerAndSorter(array<string|int, mixed> $filterParameters[, Pager|null $pager = null ][, array<string|int, mixed> $sorters = [] ]) : CI_DB_result
Parameters
- $filterParameters : array<string|int, mixed>
-
Contains the column slug-names and their values.
- $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
CI_DB_result —_getFieldMap()
return the child class Field Map array.
protected
_getFieldMap() : mixed
Return values
mixed —_getPaymentOrShippingTitle()
Returns the title of the given payment or shipping title.
protected
_getPaymentOrShippingTitle(string $method, string $type) : string
Parameters
- $method : string
-
Payment or shipping method.
- $type : string
-
Whether "payment" or "shipping".
Return values
string —_group()
Execute the group by statement.
protected
_group() : OrderListGenerator
Return values
OrderListGenerator —Returns the instance object for method chaining.
_invoicesColumns()
Returns a string for the ::_select() method which contains fallback implosion of all invoice IDs of the order if no value is set in the orders table.
protected
_invoicesColumns() : string
Return values
string —_order()
Set the order by clause of the query.
protected
_order([StringType $orderBy = null ]) : OrderListGenerator
Parameters
- $orderBy : StringType = null
Return values
OrderListGenerator —Returns the instance object for method chaining.
_ordersColumns()
Returns a string for the ::_select() method which contains column names of the orders table.
protected
_ordersColumns() : string
Return values
string —_ordersStatusColumns()
Returns a string for the ::_select() method which contains column names of the orders status table.
protected
_ordersStatusColumns() : string
Return values
string —_ordersTotalColumns()
Returns a string for the ::_select() method which contains column names of the orders total table.
protected
_ordersTotalColumns() : string
Return values
string —_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()
Prepare the OrderListItemCollection object.
protected
_prepareCollection(array<string|int, mixed> $result) : OrderListItemCollection
This method will prepare the collection object which is going to be returned by both the "get" and "filter" methods. The following values are required to be present in each row of the $result parameter:
- orders_id
- customers_id
- customers_firstname
- customers_lastname
- date_purchased
- payment_class
- payment_method
- shipping_class
- shipping_method
- orders_status_id
- orders_status_name
- total_sum
Parameters
- $result : array<string|int, mixed>
-
Contains the order data.
Tags
Return values
OrderListItemCollection —_select()
Execute the select and join methods.
protected
_select([ $filterParameters = null ][, $sorters = [] ]) : OrderListGenerator
Parameters
Return values
OrderListGenerator —Returns the instance object for method chaining.
_setFilterArguments()
Set the where clauses for the filtered order records query.
protected
_setFilterArguments(array<string|int, mixed> $filterParameters[, Pager|null $pager = null ][, array<string|int, mixed> $sorters = [] ]) : OrderListGeneratorInterface
This method contains the filtering logic. It can be overloaded in order to provide a custom filtering logic.
Parameters
- $filterParameters : array<string|int, mixed>
-
Contains the column slug-names and their values.
- $pager : Pager|null = null
-
(Optional) Pager object with pagination information
- $sorters : array<string|int, mixed> = []
-
(Optional) array of Sorter objects with data sorting information
Tags
Return values
OrderListGeneratorInterface —Same instance for chained method calls.
_setKeywordWhereClause()
protected
_setKeywordWhereClause(StringType $keyword) : mixed
Parameters
- $keyword : StringType
-
Keyword string to be used for searching in order records.
Return values
mixed —_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.
getAllOrderStatuses()
Returns all order statuses using the default language
protected
getAllOrderStatuses() : array<string|int, mixed>
Return values
array<string|int, mixed> —getOrderTotalSum()
Returns the total sum for the selected orders
protected
getOrderTotalSum( $orders) : array<string|int, mixed>