function uc_attribute_subject_exists in Ubercart 8.4
Same name and namespace in other branches
- 6.2 uc_attribute/uc_attribute.module \uc_attribute_subject_exists()
- 7.3 uc_attribute/uc_attribute.module \uc_attribute_subject_exists()
Checks if a product/class attribute exists.
Parameters
int $aid: The base attribute ID.
string $type: The type of attribute: 'product' or 'class'. Any other type will fetch a base attribute.
int $id: The product/class attribute's ID.
Return value
bool TRUE if the attribute exists.
2 calls to uc_attribute_subject_exists()
- AttributeTest::testAttributeApi in uc_attribute/
tests/ src/ Functional/ AttributeTest.php - Tests the basic attribute API.
- uc_attribute_subject_save in uc_attribute/
uc_attribute.module - Saves a product/class attribute.
File
- uc_attribute/
uc_attribute.module, line 998 - Ubercart Attribute module.
Code
function uc_attribute_subject_exists($aid, $type, $id) {
$sql = uc_attribute_type_info($type);
$connection = \Drupal::database();
$query = $connection
->select($sql['attr_table'], 'a')
->fields('a', [
'aid',
])
->condition('aid', $aid)
->condition($sql['id'], $id);
return FALSE !== $query
->execute()
->fetchField();
}