You are here

function uc_attribute_subject_option_load in Ubercart 8.4

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

Loads a product/class attribute option.

Parameters

int $oid: The product/class attribute option ID.

string $type: The type of attribute: 'product' or 'class'. Any other type will fetch a base attribute.

int $id: The product/class ID.

Return value

object An object containing the product/class attribute option.

1 call to uc_attribute_subject_option_load()
AttributeTest::testAttributeUiClassAttributeOptionOverview in uc_attribute/tests/src/Functional/AttributeTest.php
Tests the product class attribute option user interface.

File

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

Code

function uc_attribute_subject_option_load($oid, $type, $id) {
  $sql = uc_attribute_type_info($type);
  $connection = \Drupal::database();
  $query = $connection
    ->select($sql['opt_table'], 'po');
  $query
    ->leftJoin('uc_attribute_options', 'ao', 'po.oid = ao.oid');
  $query
    ->fields('po', [
    $sql['id'],
    'oid',
    'cost',
    'price',
    'weight',
    'ordering',
  ])
    ->fields('ao', [
    'name',
    'aid',
  ])
    ->condition('po.oid', $oid)
    ->condition("po.{$sql['id']}", $id)
    ->orderBy('po.ordering')
    ->orderBy('ao.name');
  return $query
    ->execute()
    ->fetchObject();
}