Remove global_unique_id from interface and add warning in case it is not implemented (#50685)
This commit is contained in:
parent
bcf1a38a58
commit
70fc2d595e
|
@ -0,0 +1,5 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
Comment: Remove global_unique_id from interface and add warning in case it is not implemented
|
||||
|
||||
|
|
@ -41,15 +41,6 @@ interface WC_Product_Data_Store_Interface {
|
|||
*/
|
||||
public function is_existing_sku( $product_id, $sku );
|
||||
|
||||
/**
|
||||
* Check if product unique ID is found for any other product IDs.
|
||||
*
|
||||
* @param int $product_id Product ID.
|
||||
* @param string $global_unique_id Unique ID.
|
||||
* @return bool
|
||||
*/
|
||||
public function is_existing_global_unique_id( $product_id, $global_unique_id );
|
||||
|
||||
/**
|
||||
* Return product ID based on SKU.
|
||||
*
|
||||
|
@ -58,13 +49,6 @@ interface WC_Product_Data_Store_Interface {
|
|||
*/
|
||||
public function get_product_id_by_sku( $sku );
|
||||
|
||||
/**
|
||||
* Return product ID based on Unique ID.
|
||||
*
|
||||
* @param string $global_unique_id Unique ID.
|
||||
* @return int
|
||||
*/
|
||||
public function get_product_id_by_global_unique_id( $global_unique_id );
|
||||
|
||||
/**
|
||||
* Returns an array of IDs of products that have sales starting soon.
|
||||
|
|
|
@ -662,8 +662,13 @@ function wc_product_has_global_unique_id( $product_id, $global_unique_id ) {
|
|||
return boolval( $has_global_unique_id );
|
||||
}
|
||||
|
||||
$data_store = WC_Data_Store::load( 'product' );
|
||||
$global_unique_id_found = $data_store->is_existing_global_unique_id( $product_id, $global_unique_id );
|
||||
$data_store = WC_Data_Store::load( 'product' );
|
||||
if ( $data_store->has_callable( 'is_existing_global_unique_id' ) ) {
|
||||
$global_unique_id_found = $data_store->is_existing_global_unique_id( $product_id, $global_unique_id );
|
||||
} else {
|
||||
$logger = wc_get_logger();
|
||||
$logger->error( 'The method is_existing_global_unique_id is not implemented in the data store.', array( 'source' => 'wc_product_has_global_unique_id' ) );
|
||||
}
|
||||
/**
|
||||
* Gives plugins an opportunity to verify Unique ID uniqueness themselves.
|
||||
*
|
||||
|
@ -738,11 +743,17 @@ function wc_get_product_id_by_sku( $sku ) {
|
|||
*
|
||||
* @since 9.1.0
|
||||
* @param string $global_unique_id Product Unique ID.
|
||||
* @return int
|
||||
* @return int|null
|
||||
*/
|
||||
function wc_get_product_id_by_global_unique_id( $global_unique_id ) {
|
||||
$data_store = WC_Data_Store::load( 'product' );
|
||||
return $data_store->get_product_id_by_global_unique_id( $global_unique_id );
|
||||
if ( $data_store->has_callable( 'get_product_id_by_global_unique_idz' ) ) {
|
||||
return $data_store->get_product_id_by_global_unique_id( $global_unique_id );
|
||||
} else {
|
||||
$logger = wc_get_logger();
|
||||
$logger->error( 'The method get_product_id_by_global_unique_id is not implemented in the data store.', array( 'source' => 'wc_get_product_id_by_global_unique_id' ) );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue