WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Internal\ProductAttributesLookup

LookupDataStore::get_update_action() private WC 1.0

Determine the type of action to perform depending on the received changeset.

{} It's a method of the class: LookupDataStore{}

No Hooks.

Return

Int. One of the ACTION_ constants.

Usage

// private - for code of main (parent) class only
$result = $this->get_update_action( $changeset );
$changeset(array|null) (required)
The changeset received by on_product_changed.

Code of LookupDataStore::get_update_action() WC 5.9.0

private function get_update_action( $changeset ) {
	if ( is_null( $changeset ) ) {
		// No changeset at all means that the product is new.
		return self::ACTION_INSERT;
	}

	$keys = array_keys( $changeset );

	// Order matters:
	// - The change with the most precedence is a change in catalog visibility
	// (which will result in all data being regenerated or deleted).
	// - Then a change in attributes (all data will be regenerated).
	// - And finally a change in stock status (existing data will be updated).
	// Thus these conditions must be checked in that same order.

	if ( in_array( 'catalog_visibility', $keys, true ) ) {
		$new_visibility = $changeset['catalog_visibility'];
		if ( 'visible' === $new_visibility || 'catalog' === $new_visibility ) {
			return self::ACTION_INSERT;
		} else {
			return self::ACTION_DELETE;
		}
	}

	if ( in_array( 'attributes', $keys, true ) ) {
		return self::ACTION_INSERT;
	}

	if ( array_intersect( $keys, array( 'stock_quantity', 'stock_status', 'manage_stock' ) ) ) {
		return self::ACTION_UPDATE_STOCK;
	}

	return self::ACTION_NONE;
}