Automattic\WooCommerce\Internal\CLI\Migrator\Platforms\Webflow
WebflowMapper::map_basic_fields
Map fields common to every product (name, slug, description, status…).
Method of the class: WebflowMapper{}
No Hooks.
Returns
array.
Usage
// private - for code of main (parent) class only $result = $this->map_basic_fields( $product, $field_data, $is_variable ): array;
- $product(object) (required)
- Product object.
- $field_data(object) (required)
- Field data object.
- $is_variable(true|false) (required)
- Whether this product has multiple SKUs to expose as variations.
WebflowMapper::map_basic_fields() WebflowMapper::map basic fields code WC 11.1.2
private function map_basic_fields( object $product, object $field_data, bool $is_variable ): array {
$basic = array();
$basic['is_variable'] = $is_variable;
$basic['original_product_id'] = isset( $product->id ) ? (string) $product->id : null;
$basic['name'] = isset( $field_data->name ) ? sanitize_text_field( (string) $field_data->name ) : '';
$basic['slug'] = isset( $field_data->slug ) ? sanitize_title( (string) $field_data->slug ) : sanitize_title( $basic['name'] );
$basic['description'] = isset( $field_data->description ) ? wp_kses_post( (string) $field_data->description ) : '';
$short_description_key = 'short-description';
$basic['short_description'] = isset( $field_data->{$short_description_key} )
? wp_kses_post( (string) $field_data->{$short_description_key} )
: '';
// Status and visibility mirror the source on every import, so a re-run resets any manual
// draft/hide a merchant applied to a previously imported product. This is intentional: the
// migrator treats Webflow as the source of truth for these fields.
$basic['status'] = $this->map_status( $product );
$basic['catalog_visibility'] = 'visible';
if ( isset( $product->createdOn ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- Webflow API uses camelCase.
$basic['date_created_gmt'] = (string) $product->createdOn; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- Webflow API uses camelCase.
}
if ( isset( $product->lastUpdated ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- Webflow API uses camelCase.
$basic['date_modified_gmt'] = (string) $product->lastUpdated; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- Webflow API uses camelCase.
}
$basic['brand'] = null;
return $basic;
}