function getProductAttributeId($view_tag_name, $default_value = null) { global $application; if (!is_object($application)) { return $default_value; } $attr_ids_cache = $application->getAttrIdsCache(); $attr_id = $attr_ids_cache->read($view_tag_name); if ($attr_id == null) { if ($application->db->DB_isTableExists($application->getAppIni('DB_TABLE_PREFIX') . "attributes") != null) { $s = new DB_Select(); $s->addSelectTable("attributes"); $s->addSelectField('attribute_id', 'attribute_id'); $s->WhereValue('attribute_view_tag', DB_EQ, $view_tag_name); $m = new DB_MySQL(); $m->PrepareSQL($s); $result = $m->getDB_Result($s); $attr_id = !empty($result) ? $result[0]['attribute_id'] : $default_value; } else { $attr_id = $default_value; } $attr_ids_cache->write($view_tag_name, $attr_id); } return $attr_id; }