You are here

function uc_dropdown_attributes_node_insert in Dropdown Attributes 8

Implements hook_node_insert().

File

./uc_dropdown_attributes.module, line 1242
A module for uc_dropdown_attributes.

Code

function uc_dropdown_attributes_node_insert($node) {
  $count = \Drupal::database()
    ->select('uc_class_attributes', 'ca')
    ->condition('pcid', $node
    ->getType())
    ->countQuery()
    ->execute()
    ->fetchField();
  if ($count > 0) {

    // Ubercart copies over the class attributes and class options to the
    // product so need to delete them.
    \Drupal::database()
      ->delete('uc_product_attributes')
      ->condition('nid', $node
      ->id())
      ->execute();
    \Drupal::database()
      ->delete('uc_product_options')
      ->condition('nid', $node
      ->id())
      ->execute();
  }
}