BufferChecker
in package
Table of Contents
Properties
- $actionName : string
- $checkCount : int
- $checkInterval : int
- $instance : self|null
Methods
- executeChecker() : void
- Executes the checker logic for processing the buffer.
- getInstance() : self
- Get the singleton instance of the BufferChecker class.
- removeScheduledCron() : void
- Removes the scheduled cron job if it is set.
- scheduleChecker() : void
- Schedules the cron job that runs periodically to execute the checker.
- updateOtherCollectionsSingleProduct() : bool
- Updates multiple product collections for a single product based on language and country.
- __construct() : mixed
- updateOtherCollections() : bool
- Updates product-related collections based on the number of records and specified languages.
- updateProductsCollection() : bool
- Updates product collections based on the given records and languages.
- updateSingleProduct() : bool
- Updates a single product in the collection for a given language.
Properties
$actionName
private
string
$actionName
= 'wsc_check_api_buffer'
$checkCount
private
int
$checkCount
= 100
$checkInterval
private
int
$checkInterval
= 120
$instance
private
static self|null
$instance
= null
Methods
executeChecker()
Executes the checker logic for processing the buffer.
public
executeChecker() : void
This function will be triggered when the cron job is run.
getInstance()
Get the singleton instance of the BufferChecker class.
public
static getInstance() : self
Return values
self —The instance of BufferChecker.
removeScheduledCron()
Removes the scheduled cron job if it is set.
public
removeScheduledCron() : void
scheduleChecker()
Schedules the cron job that runs periodically to execute the checker.
public
scheduleChecker([string $context = "" ]) : void
This function will schedule the cron event to run every minute. It also registers a custom cron interval.
Parameters
- $context : string = ""
updateOtherCollectionsSingleProduct()
Updates multiple product collections for a single product based on language and country.
public
updateOtherCollectionsSingleProduct(string $id, array<string|int, mixed> $blogIds, array<string|int, mixed> $classes) : bool
This function iterates through all available countries where the given language is used, and updates the product in multiple collection instances.
Parameters
- $id : string
-
The product ID to update.
- $blogIds : array<string|int, mixed>
- $classes : array<string|int, mixed>
-
An array of collection class names to update.
Return values
bool —Returns true if all updates were successful, otherwise false.
__construct()
private
__construct() : mixed
updateOtherCollections()
Updates product-related collections based on the number of records and specified languages.
private
updateOtherCollections(array<string|int, mixed> $records, array<string|int, mixed> $langs[, bool $updateAllLocales = false ]) : bool
If the number of records exceeds a predefined threshold, entire collections are regenerated. Otherwise, individual product documents are updated selectively.
Parameters
- $records : array<string|int, mixed>
-
List of product records to be updated.
- $langs : array<string|int, mixed>
-
List of languages for which the collections should be updated.
- $updateAllLocales : bool = false
-
Whether to update all locales for each record.
Return values
bool —Returns true if all updates were successful, otherwise false.
updateProductsCollection()
Updates product collections based on the given records and languages.
private
updateProductsCollection(array<string|int, mixed> $records, array<string|int, mixed> $langs[, bool $updateAllLocales = false ]) : bool
If the number of records is below a predefined threshold, individual product documents are updated. Otherwise, the entire product collection is regenerated for each language.
Parameters
- $records : array<string|int, mixed>
-
List of product records to be updated.
- $langs : array<string|int, mixed>
-
List of languages for which the collections should be updated.
- $updateAllLocales : bool = false
-
Whether to update all locales for each record.
Return values
bool —Returns true if all updates were successful, otherwise false.
updateSingleProduct()
Updates a single product in the collection for a given language.
private
updateSingleProduct(string $id, string $lang) : bool
If the product update fails, it logs an error and returns false.
Parameters
- $id : string
-
The ID of the product to be updated.
- $lang : string
-
The language for which the product update should be performed.
Return values
bool —Returns true if the product was successfully updated, otherwise false.