GoogleAnalyticsTrackingRepositoryReader
in package
implements
GoogleAnalyticsTrackingRepositoryReaderInterface
Class GoogleAnalyticsTrackingRepositoryReader
Interfaces, Classes and Traits
- GoogleAnalyticsTrackingRepositoryReaderInterface
- Interface GoogleAnalyticsTrackingRepositoryReaderInterface
Table of Contents
- $db : CI_DB_query_builder
- $netPrice : bool
- $taxCountryId : int
- __construct() : mixed
- GoogleAnalyticsTrackingRepositoryReader constructor.
- fetchImpression() : array<string|int, mixed>
- Fetches impression data by the given product id.
- fetchImpressions() : array<string|int, mixed>
- Fetches impressions data by the given product ids.
- fetchProductByCombinedId() : array<string|int, mixed>
- Fetches product data by the given combined product id.
- fetchProductByVariant() : array<string|int, mixed>
- Fetches product data by the given product id and optional variants.
- fetchPurchase() : array<string|int, mixed>
- Fetches purchase data by the given order id.
- _attributeCombinationSubSelect() : string
- Returns a select mysql query string that fetches attribute combination id.
- _attributePriceSubSelect() : string
- Returns a select mysql query string that fetches attribute price.
- _attributeVariantSubSelect() : string
- Returns a select mysql query string that fetches attribute variant names.
- _combinationIdSubSelect() : string
- Returns a select mysql query string that fetches property combination id.
- _customerGroupsMaxDiscount() : array<string|int, mixed>
- Fetches the maximal discount value for the given customer group.
- _fetchByAttributeVariant() : array<string|int, mixed>
- Fetches product data with attribute variants.
- _fetchByCombinedVariant() : array<string|int, mixed>
- Fetches product data with combined variants.
- _fetchByPropertyVariant() : array<string|int, mixed>
- Fetches product data with property variants.
- _getCompiledOrderTotalSelect() : mixed
- _gross2NetByTaxRate() : mixed
- _impressionQuerySetup() : CI_DB_query_builder
- Prepares the select query to fetch impression data.
- _net2Gross() : float
- Calculates the gross price by the given and price and product id.
- _net2GrossByTaxRate() : float
- Calculates the gross price by the given net price and tax rate.
- _prepareImpressionResult() : mixed
- Prepares the impression result data set.
- _processDiscount() : float|int
- Calculates discounts.
- _productDataQuerySetup() : CI_DB_query_builder
- Query setup to fetch the main products data.
- _unsetKeyIfExists() : $this
- Removes an array element by the given key name, if exists.
Properties
$db
protected
CI_DB_query_builder
$db
$netPrice
protected
bool
$netPrice
$taxCountryId
protected
int
$taxCountryId
Methods
__construct()
GoogleAnalyticsTrackingRepositoryReader constructor.
public
__construct(CI_DB_query_builder $db, BoolType $netPrices) : mixed
Parameters
- $db : CI_DB_query_builder
- $netPrices : BoolType
Return values
mixed —fetchImpression()
Fetches impression data by the given product id.
public
fetchImpression(IdType $productId, IdType $languageId, IdType $customerGroupId) : array<string|int, mixed>
Parameters
- $productId : IdType
-
Product id.
- $languageId : IdType
-
Language id.
- $customerGroupId : IdType
-
Customer group id.
Return values
array<string|int, mixed> —Data that contains impression information.
fetchImpressions()
Fetches impressions data by the given product ids.
public
fetchImpressions(IdCollection $productIds, IdType $languageId, IdType $customerGroupId) : array<string|int, mixed>
Parameters
- $productIds : IdCollection
-
Product ids.
- $languageId : IdType
-
Language id.
- $customerGroupId : IdType
-
Customer group id.
Return values
array<string|int, mixed> —Data that contains impressions information.
fetchProductByCombinedId()
Fetches product data by the given combined product id.
public
fetchProductByCombinedId(GoogleAnalyticsCombinedProductIdInterface $combinedProductId, IdType $languageId, IdType $customerGroupId) : array<string|int, mixed>
Parameters
- $combinedProductId : GoogleAnalyticsCombinedProductIdInterface
-
Id combination of product, attribute and property combination ids.
- $languageId : IdType
-
Language Id.
- $customerGroupId : IdType
-
Customer group Id.
Return values
array<string|int, mixed> —Data that contains product information.
fetchProductByVariant()
Fetches product data by the given product id and optional variants.
public
fetchProductByVariant(IdType $productId, IdType $languageId, IdType $customerGroupId, GoogleAnalyticsVariantInterface $variant) : array<string|int, mixed>
Parameters
- $productId : IdType
-
Product Id.
- $languageId : IdType
-
Language Id.
- $customerGroupId : IdType
-
Customer group Id.
- $variant : GoogleAnalyticsVariantInterface
-
Variants data if exists.
Return values
array<string|int, mixed> —Data that contains product information.
fetchPurchase()
Fetches purchase data by the given order id.
public
fetchPurchase(IdType $orderId) : array<string|int, mixed>
Parameters
- $orderId : IdType
-
Order Id.
Return values
array<string|int, mixed> —Data that contains purchase information.
_attributeCombinationSubSelect()
Returns a select mysql query string that fetches attribute combination id.
protected
_attributeCombinationSubSelect(int $productId, array<string|int, mixed> $attributeValueIds) : string
Parameters
- $productId : int
-
Product Id.
- $attributeValueIds : array<string|int, mixed>
-
Variants data if exists.
Return values
string —Compiled select that fetches the attribute combination id.
_attributePriceSubSelect()
Returns a select mysql query string that fetches attribute price.
protected
_attributePriceSubSelect(int $productId) : string
Parameters
- $productId : int
-
Product Id.
Return values
string —Compiled select that fetches the attribute price.
_attributeVariantSubSelect()
Returns a select mysql query string that fetches attribute variant names.
protected
_attributeVariantSubSelect(int $productId, IdType $languageId, array<string|int, mixed> $attributeOptionIds, array<string|int, mixed> $attributeValueIds) : string
Parameters
- $productId : int
-
Product Id.
- $languageId : IdType
-
Language Id.
- $attributeOptionIds : array<string|int, mixed>
-
Attribute option Ids.
- $attributeValueIds : array<string|int, mixed>
-
Attribute value Ids.
Return values
string —Compiled select that fetches the attribute variants name.
_combinationIdSubSelect()
Returns a select mysql query string that fetches property combination id.
protected
_combinationIdSubSelect(IdType $productId, GoogleAnalyticsVariantInterface $variant) : string
Parameters
- $productId : IdType
-
Product Id.
- $variant : GoogleAnalyticsVariantInterface
-
Variants data if exists.
Return values
string —Compiled select that fetches the property combination id.
_customerGroupsMaxDiscount()
Fetches the maximal discount value for the given customer group.
protected
_customerGroupsMaxDiscount(IdType $customerGroupId) : array<string|int, mixed>
Parameters
- $customerGroupId : IdType
-
Id of customer group.
Return values
array<string|int, mixed> —Discount of customer group.
_fetchByAttributeVariant()
Fetches product data with attribute variants.
protected
_fetchByAttributeVariant(IdType $productId, IdType $customerGroupId, IdType $languageId, GoogleAnalyticsVariantInterface $variant) : array<string|int, mixed>
Parameters
- $productId : IdType
-
Product Id.
- $customerGroupId : IdType
-
Customer Group Id.
- $languageId : IdType
-
Language Id.
- $variant : GoogleAnalyticsVariantInterface
-
Variants data if exists.
Return values
array<string|int, mixed> —_fetchByCombinedVariant()
Fetches product data with combined variants.
protected
_fetchByCombinedVariant(IdType $productId, IdType $customerGroupId, IdType $languageId, GoogleAnalyticsVariantInterface $variant) : array<string|int, mixed>
Parameters
- $productId : IdType
-
Product Id.
- $customerGroupId : IdType
-
Customer Group Id.
- $languageId : IdType
-
Language Id.
- $variant : GoogleAnalyticsVariantInterface
-
Variants data if exists.
Return values
array<string|int, mixed> —_fetchByPropertyVariant()
Fetches product data with property variants.
protected
_fetchByPropertyVariant(IdType $productId, IdType $customerGroupId, IdType $languageId, GoogleAnalyticsVariantInterface $variant) : array<string|int, mixed>
Parameters
- $productId : IdType
-
Product Id.
- $customerGroupId : IdType
-
Customer Group Id.
- $languageId : IdType
-
Language Id.
- $variant : GoogleAnalyticsVariantInterface
-
Variants data if exists.
Return values
array<string|int, mixed> —_getCompiledOrderTotalSelect()
protected
_getCompiledOrderTotalSelect(IdType $orderId, mixed $otClass, mixed $alias) : mixed
Parameters
- $orderId : IdType
- $otClass : mixed
- $alias : mixed
Return values
mixed —_gross2NetByTaxRate()
protected
_gross2NetByTaxRate(mixed $taxRate, mixed $grossPrice) : mixed
Parameters
- $taxRate : mixed
- $grossPrice : mixed
Return values
mixed —_impressionQuerySetup()
Prepares the select query to fetch impression data.
protected
_impressionQuerySetup(IdType $languageId, IdType $customerGroupId) : CI_DB_query_builder
Parameters
Return values
CI_DB_query_builder —Used query builder instance.
_net2Gross()
Calculates the gross price by the given and price and product id.
protected
_net2Gross(int $productId, float $netPrice) : float
The product id is required to fetch the right geo zone of the product.
Parameters
- $productId : int
-
Product id.
- $netPrice : float
-
Net price.
Return values
float —Calculated gross price.
_net2GrossByTaxRate()
Calculates the gross price by the given net price and tax rate.
protected
_net2GrossByTaxRate(float $taxRate, float $netPrice) : float
Parameters
- $taxRate : float
-
Tax rate for calculation.
- $netPrice : float
-
Net price.
Return values
float —By given tax rate and net value calculated gross price.
_prepareImpressionResult()
Prepares the impression result data set.
protected
_prepareImpressionResult(array<string|int, mixed> &$data, int $productId, array<string|int, mixed> $customerGroupDiscount) : mixed
Unnecessary elements with keys "productPrice", ""personalOffer, "specialPrice" and "allowedDiscount" will be removed.
Parameters
- $data : array<string|int, mixed>
-
Impression result data set.
- $productId : int
-
Product Id.
- $customerGroupDiscount : array<string|int, mixed>
-
Discount data for customer group.
Return values
mixed —_processDiscount()
Calculates discounts.
protected
_processDiscount(string|float $price, string|float $allowedDiscount, string|float $customerGroupMaxDiscount) : float|int
Parameters
- $price : string|float
-
Main price (will be casted to float).
- $allowedDiscount : string|float
-
Products allowed discount (will be casted to float).
- $customerGroupMaxDiscount : string|float
-
Customer groups allowed discount (will be casted to float).
Return values
float|int —New price with calculated discount.
_productDataQuerySetup()
Query setup to fetch the main products data.
protected
_productDataQuerySetup(IdType $customerGroupId, IdType $languageId) : CI_DB_query_builder
Parameters
Return values
CI_DB_query_builder —_unsetKeyIfExists()
Removes an array element by the given key name, if exists.
protected
_unsetKeyIfExists(array<string|int, mixed> &$data, string $key) : $this
Parameters
- $data : array<string|int, mixed>
-
Array to be mutated.
- $key : string
-
Key of element to be removed.
Return values
$this —Same instance for chained method calls.