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.
Return
null
. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->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 9.5.1
private 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; } }