Automattic\WooCommerce\Internal\ProductAttributesLookup

LookupDataStore::on_product_changed()publicWC 1.0

Insert/update the appropriate lookup table entries for a new or modified product or variation. This must be invoked after a product or a variation is created (including untrashing and duplication) or modified.

Method of the class: LookupDataStore{}

No Hooks.

Return

null. Nothing (null).

Usage

$LookupDataStore = new LookupDataStore();
$LookupDataStore->on_product_changed( $product, $changeset );
$product(int|\WC_Product) (required)
Product object or product id.
$changeset(null|array)
Changes as provided by 'get_changes' method in the product object, null if it's being created.
Default: null

LookupDataStore::on_product_changed() code WC 8.7.0

public function on_product_changed( $product, $changeset = null ) {
	if ( ! $this->check_lookup_table_exists() ) {
		return;
	}

	if ( ! is_a( $product, \WC_Product::class ) ) {
		$product = WC()->call_function( 'wc_get_product', $product );
	}

	$action = $this->get_update_action( $changeset );
	if ( $action !== self::ACTION_NONE ) {
		$this->maybe_schedule_update( $product->get_id(), $action );
	}
}