Automattic\WooCommerce\Internal\CLI\Migrator\Core
WooCommerceProductImporter::create_product_object
Create appropriate product object based on type.
Method of the class: WooCommerceProductImporter{}
No Hooks.
Returns
WC_Product|null. Product object or null on failure.
Usage
// private - for code of main (parent) class only $result = $this->create_product_object( $product_type ): ?WC_Product;
- $product_type(string) (required)
- Product type.
WooCommerceProductImporter::create_product_object() WooCommerceProductImporter::create product object code WC 10.8.1
private function create_product_object( string $product_type ): ?WC_Product {
switch ( $product_type ) {
case 'variable':
return new WC_Product_Variable();
case 'simple':
default:
return new WC_Product_Simple();
}
}