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.
- Full name:
\BigCommerce\Import\Processors\Term_Import
- This class implements:
\BigCommerce\Import\Processors\Import_Processor
- This class is an Abstract class
Constants
Constant | Visibility | Type | Value |
---|---|---|---|
STATE_OPTION | public | string | ’bigcommerce_import_terms_state’ |
BRANDS_CHECKPOINT | public | string | ’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:
Parameter | Type | Description |
---|---|---|
$catalog_api | \BigCommerce\Api\v3\Api\CatalogApi | Instance of the Catalog API client. |
$gql_processor | \BigCommerce\GraphQL\GraphQL_Processor | Instance of the GraphQL processor. |
$batch_size | int | Number 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:
Parameter | Type | Description |
---|---|---|
$term | \StdClass | The term object to import. |
$fallback | bool | Whether 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:
Parameter | Type | Description |
---|---|---|
$cursor | string | Optional. 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:
Parameter | Type | Description |
---|---|---|
$term | \StdClass|null | The 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:
Parameter | Type | Description |
---|---|---|
$raw_response | string | The 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:
Parameter | Type | Description |
---|---|---|
$page | int | The page number to set. |
Inherited methods
get_option
protected get_option(string $option, bool $default = false): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$option | string | |
$default | bool |
update_option
protected update_option(string $option, mixed $value, bool $autoload = false): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$option | string | |
$value | mixed | |
$autoload | bool |
add_option
protected add_option(string $option, mixed $value, bool $autoload = false): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$option | string | |
$value | mixed | |
$autoload | bool |
delete_option
protected delete_option(string $option): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$option | string |
Automatically generated on 2025-01-21