You are here

function uc_attribute_delete in Ubercart 8.4

Same name and namespace in other branches
  1. 6.2 uc_attribute/uc_attribute.module \uc_attribute_delete()
  2. 7.3 uc_attribute/uc_attribute.module \uc_attribute_delete()

Deletes an attribute from the database.

Parameters

int $aid: Attribute ID to delete.

Return value

int The Drupal SAVED_DELETED flag.

1 call to uc_attribute_delete()
AttributeTest::testAttributeApi in uc_attribute/tests/src/Functional/AttributeTest.php
Tests the basic attribute API.

File

uc_attribute/uc_attribute.module, line 636
Ubercart Attribute module.

Code

function uc_attribute_delete($aid) {

  // Delete the class attributes and their options.
  uc_attribute_subject_delete($aid, 'class');

  // Delete the product attributes and their options.
  uc_attribute_subject_delete($aid, 'product');

  // Delete base attributes and their options.
  $connection = \Drupal::database();
  $connection
    ->delete('uc_attribute_options')
    ->condition('aid', $aid)
    ->execute();
  $connection
    ->delete('uc_attributes')
    ->condition('aid', $aid)
    ->execute();
  return SAVED_DELETED;
}