Automattic\WooCommerce\Internal\ProductAttributesLookup

DataRegenerator::get_last_existing_product_id()privateWC 1.0

Get the highest existing product id.

Method of the class: DataRegenerator{}

No Hooks.

Return

Int|null. Highest existing product id, or null if no products exist at all.

Usage

// private - for code of main (parent) class only
$result = $this->get_last_existing_product_id(): ?int;

DataRegenerator::get_last_existing_product_id() code WC 7.1.0

private function get_last_existing_product_id(): ?int {
	$last_existing_product_id_array =
		WC()->call_function(
			'wc_get_products',
			array(
				'return'  => 'ids',
				'limit'   => 1,
				'orderby' => array(
					'ID' => 'DESC',
				),
			)
		);

	return empty( $last_existing_product_id_array ) ? null : current( $last_existing_product_id_array );
}