ClassesBigCommerceImportProcessorsTerm Import

Term_Import

Abstract class for processing term imports.

This class provides common functionality for importing terms into WordPress. It interacts with BigCommerce’s API and uses GraphQL data for creating or updating terms.

Constants

ConstantVisibilityTypeValue
STATE_OPTIONpublicstring’bigcommerce_import_terms_state’
BRANDS_CHECKPOINTpublicstring’bigcommerce_import_brands_checkpoint’

Properties

catalog_api

public \BigCommerce\Api\v3\Api\CatalogApi $catalog_api

gql_processor

public \BigCommerce\GraphQL\GraphQL_Processor $gql_processor

batch_size

public int $batch_size

Methods

__construct

Constructor for the Term_Import class.

public __construct(\BigCommerce\Api\v3\Api\CatalogApi $catalog_api, \BigCommerce\GraphQL\GraphQL_Processor $gql_processor, int $batch_size): mixed

Parameters:

ParameterTypeDescription
$catalog_api\BigCommerce\Api\v3\Api\CatalogApiInstance of the Catalog API client.
$gql_processor\BigCommerce\GraphQL\GraphQL_ProcessorInstance of the GraphQL processor.
$batch_sizeintNumber of terms to process in a single batch.

taxonomy

Get the name of the taxonomy being updated.

protected taxonomy(): string
  • This method is abstract.

Return Value:

The taxonomy name.


get_fallback_terms

Get fallback terms in case the main source data is unavailable.

protected get_fallback_terms(): array
  • This method is abstract.

Return Value:

An array of fallback terms.


running_state

Get the state name to set while the import is running.

protected running_state(): string
  • This method is abstract.

Return Value:

The running state name.


completed_state

Get the state name to set when the import is complete.

protected completed_state(): string
  • This method is abstract.

Return Value:

The completed state name.


run

Execute the term import process.

public run(): void

This method fetches terms from the source, processes them, and updates the import status as it progresses.


do_term_import

Process and import a single term.

protected do_term_import(\StdClass $term, bool $fallback = false): void

Parameters:

ParameterTypeDescription
$term\StdClassThe term object to import.
$fallbackboolWhether to use fallback data for this import.

get_source_data

Fetch term data from the source.

public get_source_data(string $cursor = ''): array
  • This method is abstract.

Parameters:

ParameterTypeDescription
$cursorstringOptional. A cursor for paginated results.

Return Value:

The API response object.

Throws:

If the API request fails.


parse_gql_term

Parse a GraphQL term object into an array format.

protected parse_gql_term(\StdClass|null $term = null): array
  • This method is abstract.

Parameters:

ParameterTypeDescription
$term\StdClass|nullThe GraphQL term object.

Return Value:

The parsed term data.


handle_graph_ql_response

Parse a GraphQL response and handle pagination if necessary.

protected handle_graph_ql_response(string $raw_response = ''): array|mixed

Parameters:

ParameterTypeDescription
$raw_responsestringThe raw GraphQL response.

Return Value:

Parsed term data or a cursor for the next page of results.


get_page

Get the current page for the import process.

protected get_page(): int

Return Value:

The current page number.


set_page

Set the current page for the import process.

protected set_page(int $page): void

Parameters:

ParameterTypeDescription
$pageintThe page number to set.

Inherited methods

get_option

protected get_option(string $option, bool $default = false): mixed

Parameters:

ParameterTypeDescription
$optionstring
$defaultbool

update_option

protected update_option(string $option, mixed $value, bool $autoload = false): bool

Parameters:

ParameterTypeDescription
$optionstring
$valuemixed
$autoloadbool

add_option

protected add_option(string $option, mixed $value, bool $autoload = false): bool

Parameters:

ParameterTypeDescription
$optionstring
$valuemixed
$autoloadbool

delete_option

protected delete_option(string $option): bool

Parameters:

ParameterTypeDescription
$optionstring


Automatically generated on 2025-01-21