ClassesBigCommerceImportProcessorsBrand Import

Brand_Import

This class handles the import process for BigCommerce brands. It extends the base Term_Import class and provides the specific functionality for importing and updating brand terms in WordPress.

Properties

batch

protected array $batch

Methods

taxonomy

Get the taxonomy name for the brand import.

protected taxonomy(): string

This method returns the taxonomy name specific to brands in BigCommerce.

Return Value:

The name of the taxonomy.


running_state

Get the state for the running process.

protected running_state(): string

This method returns the status representing the running state of the brand import.

Return Value:

The status indicating the import is running.


completed_state

Get the state for the completed process.

protected completed_state(): string

This method returns the status representing the completion of the brand import.

Return Value:

The status indicating the import is completed.


parse_gql_term

Parse the BigCommerce GraphQL term data and map it to a GQL_Term_Model.

protected parse_gql_term(\stdClass|null $term = null): array

This method processes the raw GraphQL term data and transforms it into a standardized GQL_Term_Model object, adjusting certain properties such as the description and image URL.

Parameters:

ParameterTypeDescription
$term\stdClass|nullThe GraphQL term data to parse.

Return Value:

An array containing the GQL_Term_Model instance(s).


get_source_data

Get the source data for the brand import from BigCommerce.

public get_source_data(string $cursor = ''): array

This method fetches brand data from BigCommerce using GraphQL and handles the response. If the response includes a cursor, it recursively retrieves the next set of data.

Parameters:

ParameterTypeDescription
$cursorstringThe cursor to fetch the next set of data (optional).

Return Value:

The list of brand terms fetched from the BigCommerce API.

Throws:

If there is an error retrieving the data.


get_fallback_terms

Get the fallback terms if GraphQL data retrieval fails.

protected get_fallback_terms(): array

This method retrieves brand data using the Catalog API if GraphQL data cannot be fetched. It handles pagination and ensures that all brand data is retrieved.

Return Value:

The list of fallback brand terms fetched from the Catalog API.


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

__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.


Automatically generated on 2025-01-21