You are here

function uc_product_node_update in Ubercart 8.4

Implements hook_node_update().

1 call to uc_product_node_update()
uc_product_node_insert in uc_product/uc_product.module
Implements hook_node_insert().

File

uc_product/uc_product.module, line 76
The product module for Ubercart.

Code

function uc_product_node_update($node) {
  if (!uc_product_is_product($node)) {
    return;
  }
  $connection = \Drupal::database();
  $connection
    ->merge('uc_products')
    ->keys([
    'vid' => $node
      ->getRevisionId(),
    'nid' => $node
      ->id(),
  ])
    ->fields([
    'model' => $node->model->value,
    'cost' => $node->cost->value,
    'price' => $node->price->value,
    'weight' => $node->weight->value,
    'weight_units' => $node->weight->units,
    'length' => $node->dimensions->length,
    'width' => $node->dimensions->width,
    'height' => $node->dimensions->height,
    'length_units' => $node->dimensions->units,
    'pkg_qty' => $node->pkg_qty->value,
    'default_qty' => $node->default_qty->value,
    'shippable' => (int) $node->shippable->value,
  ])
    ->execute();
}