/** * Get the value of the field $field_name for product $product_id from the product table * * @param int $product_id * @param string $field_name * @return string The value of the field $field_name for that product */ function get_field( $product_id, $field_name, $force = false ) { if( $product_id == 0 ) return ''; $db = new ps_DB; if( !isset($GLOBALS['product_info'][$product_id][$field_name] ) || $force ) { $q = 'SELECT product_id, `#__{vm}_product`.* FROM `#__{vm}_product` WHERE `product_id`='.(int)$product_id; $db->query($q); if ($db->next_record()) { $values = get_object_vars( $db->getCurrentRow() ); foreach( $values as $key => $value ) { $GLOBALS['product_info'][$product_id][$key] = $value; } if( !isset( $GLOBALS['product_info'][$product_id][$field_name] ) && !is_null($GLOBALS['product_info'][$product_id][$field_name])) { $GLOBALS['vmLogger']->debug( 'The Field '.$field_name. ' does not exist in the product table!'); $GLOBALS['product_info'][$product_id][$field_name] = true; } } else { $GLOBALS['product_info'][$product_id][$field_name] = false; } } return $GLOBALS['product_info'][$product_id][$field_name]; }