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
- getAnyBlogId() : int|null
- updateAttributesCollection() : bool
- Updates attributes collection based on the given records.
- updateExternalProductsCollection() : bool
- Updates external products collection (only when a full regeneration is required).
- updateOtherCollections() : bool
- Updates localized collections derived from products.
- updateProductsCollection() : bool
- Updates the global ProductsCollection based on buffered product records.
- updateSingleProduct() : bool
- Updates a single product in the collection.
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
getAnyBlogId()
private
getAnyBlogId() : int|null
Return values
int|nullupdateAttributesCollection()
Updates attributes collection based on the given records.
private
updateAttributesCollection(array<string|int, mixed> $records) : bool
Parameters
- $records : array<string|int, mixed>
Return values
boolupdateExternalProductsCollection()
Updates external products collection (only when a full regeneration is required).
private
updateExternalProductsCollection(bool $forceFullRebuild) : bool
Parameters
- $forceFullRebuild : bool
Return values
boolupdateOtherCollections()
Updates localized collections derived from products.
private
updateOtherCollections(array<string|int, mixed> $records, array<string|int, mixed> $langs[, bool $updateAllLocales = false ][, bool $forceFullRebuild = false ]) : bool
If the number of records exceeds a predefined threshold (or forceFullRebuild is true), entire collections are regenerated for each site. 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.
- $forceFullRebuild : bool = false
-
Forces full regeneration of localized collections.
Return values
bool —Returns true if all updates were successful, otherwise false.
updateProductsCollection()
Updates the global ProductsCollection based on buffered product records.
private
updateProductsCollection(array<string|int, mixed> $records) : bool
If the number of records is below a predefined threshold, individual product documents are updated. Otherwise, the entire products collection is regenerated once (not per locale).
Parameters
- $records : array<string|int, mixed>
-
List of product records to be updated.
Return values
bool —Returns true if all updates were successful, otherwise false.
updateSingleProduct()
Updates a single product in the collection.
private
updateSingleProduct(string $id, ProductsCollection $productsColl) : bool
If the product update fails, it logs an error and returns false.
Parameters
- $id : string
-
The ID of the product to be updated.
- $productsColl : ProductsCollection
Return values
bool —Returns true if the product was successfully updated, otherwise false.