Automattic\WooCommerce\Internal\ProductAttributesLookup
LookupDataStore::run_update_callback
Perform an update of the lookup table for a specific product.
Method of the class: LookupDataStore{}
No Hooks.
Returns
null. Nothing (null).
Usage
$LookupDataStore = new LookupDataStore(); $LookupDataStore->run_update_callback( $product_id, $action );
- $product_id(int) (required)
- The product id to perform the update for.
- $action(int) (required)
- The action to perform, one of the ACTION_ constants.
LookupDataStore::run_update_callback() LookupDataStore::run update callback code WC 10.3.3
public function run_update_callback( int $product_id, int $action ) {
if ( ! $this->check_lookup_table_exists() ) {
return;
}
$product = WC()->call_function( 'wc_get_product', $product_id );
if ( ! $product ) {
$action = self::ACTION_DELETE;
}
switch ( $action ) {
case self::ACTION_INSERT:
$this->delete_data_for( $product_id );
if ( $this->optimized_db_access_is_enabled ) {
$this->create_data_for_product_cpt( $product_id );
} else {
$this->create_data_for( $product );
}
break;
case self::ACTION_UPDATE_STOCK:
$this->update_stock_status_for( $product );
break;
case self::ACTION_DELETE:
$this->delete_data_for( $product_id );
break;
}
}