Automattic\WooCommerce\Internal\CLI\Migrator\Platforms\Shopify
ShopifyMapper::map_product_data
Maps raw Shopify product data to a standardized array format.
Method of the class: ShopifyMapper{}
No Hooks.
Returns
Array. Standardized data array for WooCommerce_Product_Importer.
Usage
$ShopifyMapper = new ShopifyMapper(); $ShopifyMapper->map_product_data( $shopify_product ): array;
- $shopify_product(object) (required)
- The raw Shopify product node from GraphQL.
ShopifyMapper::map_product_data() ShopifyMapper::map product data code WC 10.8.1
public function map_product_data( object $shopify_product ): array {
$is_variable = $this->is_variable_product( $shopify_product );
$wc_data = $this->map_basic_product_fields( $shopify_product, $is_variable );
// Map simple product data (for non-variable products).
if ( ! $is_variable ) {
$simple_data = $this->map_simple_product_data( $shopify_product );
$wc_data = array_merge( $wc_data, $simple_data );
}
// Map product images.
$wc_data['images'] = $this->map_product_images( $shopify_product );
// Map metafields and SEO data.
$wc_data['metafields'] = $this->map_metafields( $shopify_product );
// Map variable product data (attributes and variations).
$variable_data = $this->map_variable_product_data( $shopify_product, $is_variable );
$wc_data = array_merge( $wc_data, $variable_data );
return $wc_data;
}