Cleanup

Handles the cleanup process for BigCommerce imports, including purging product and user transients, cleaning up queued tasks, and flushing cache related to products and customer groups.

Constants

ConstantVisibilityTypeValue
CLEAN_USERS_TRANSIENTpublicstring’bigcommerce_users_transient_clean’
PURGE_PRODUCTSpublicstring’bigcommerce_purge_products_headless’
CLEAN_PRODUCTS_TRANSIENTpublicstring’bigcommerce_products_transient_clean’
CLEAN_POSTS_PER_PAGEpublicint25

Methods

__construct

Cleanup constructor.

public __construct(\BigCommerce\Cache\Cache_Handler $cache_handler, int $batch = self::CLEAN_POSTS_PER_PAGE): mixed

Initializes the cleanup process with a specified batch size and cache handler.

Parameters:

ParameterTypeDescription
$cache_handler\BigCommerce\Cache\Cache_HandlerCache handler instance for cache management.
$batchintNumber of records to clean up per batch. Defaults to CLEAN_POSTS_PER_PAGE.

run

Run the cleanup process.

public run(bool $abort = false, bool $pre_import = false): mixed

This method performs cleanup operations such as cleaning queued tasks, purging products, and cleaning up user transients. It also schedules additional cleanup tasks if necessary.

Parameters:

ParameterTypeDescription
$abortboolWhether to abort the cleanup process.
$pre_importboolWhether this cleanup is before or after the import.

clean_customer_group_transients

Clean customer group transients after synchronization.

public clean_customer_group_transients(): void

This method removes transient cache related to customer groups after the sync to ensure fresh data is retrieved.


refresh_products_transient

Refresh the product transient cache.

public refresh_products_transient(int $offset, bool $partially = false): void

This method flushes the product transient cache, either partially or fully, depending on the partially flag.

Parameters:

ParameterTypeDescription
$offsetintThe number of posts to skip when fetching products.
$partiallyboolWhether to perform a partial cache refresh or a full refresh.

refresh_product_source

Refresh the product source cache or pre-cache for smoother initial load.

public refresh_product_source(int $post_id): mixed

This method either refreshes the product source cache or performs a pre-cache operation to speed up the initial product load.

Parameters:

ParameterTypeDescription
$post_idintThe post ID of the product to refresh or pre-cache.


Automatically generated on 2025-01-21