Cherry pick 50685 into release/9.2 (#50705)

* Remove global_unique_id from interface and add warning in case it is not implemented (#50685)

* Prep for cherry pick 50685

* Cherry-pick 50702 into this cherry-pick :)

* Update changelog

---------

Co-authored-by: Nathan Silveira <nsschneider1@gmail.com>
Co-authored-by: WooCommerce Bot <no-reply@woocommerce.com>
Co-authored-by: Jorge Torres <jorge.torres@automattic.com>
This commit is contained in:
github-actions[bot] 2024-08-16 14:39:17 -03:00 committed by GitHub
parent 7650d408df
commit 8039a96735
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 20 deletions

View File

@ -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.

View File

@ -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_id' ) ) {
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;
}
/**

View File

@ -173,6 +173,7 @@ WooCommerce comes with some sample data you can use to see how products look; im
**WooCommerce**
* Fix - Remove global_unique_id from interface and add warning in case it is not implemented [#50685](https://github.com/woocommerce/woocommerce/pull/50685)
* Fix - CYS: avoid to enqueue Jetpack scripts [#50679](https://github.com/woocommerce/woocommerce/pull/50679)
* Fix - Clear product unique ID (`global_unique_id`) when duplicating products. [#50629](https://github.com/woocommerce/woocommerce/pull/50629)
* Fix - Resolved an issue that caused the page title and content text to display in the incorrect order on the Order Confirmation page. [#50592](https://github.com/woocommerce/woocommerce/pull/50592)