You are here

function uc_product_get_attributes in Ubercart 8.4

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

Loads all attributes associated with a product node.

Parameters

int $nid: The product node id.

Return value

array The attributes.

9 calls to uc_product_get_attributes()
CartLinksTest::createValidCartLinks in uc_cart_links/src/Tests/CartLinksTest.php
Creates Cart Links pointing to the given product(s).
ProductAttributesAddForm::buildForm in uc_attribute/src/Form/ProductAttributesAddForm.php
Form constructor.
ProductAttributesForm::buildForm in uc_attribute/src/Form/ProductAttributesForm.php
Form constructor.
ProductOptionsForm::buildForm in uc_attribute/src/Form/ProductOptionsForm.php
Form constructor.
uc_attribute_buy_it_now_form_validate in uc_attribute/uc_attribute.module
Validation callback for "buy it now" forms with attributes.

... See full list

File

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

Code

function uc_product_get_attributes($nid) {
  $attributes = [];
  $connection = \Drupal::database();
  $result = $connection
    ->query("SELECT upa.aid FROM {uc_product_attributes} upa LEFT JOIN {uc_attributes} ua ON upa.aid = ua.aid WHERE upa.nid = :nid ORDER BY upa.ordering, ua.name", [
    ':nid' => $nid,
  ]);
  foreach ($result as $attribute) {
    $attributes[$attribute->aid] = uc_attribute_load($attribute->aid, $nid, 'product');
  }
  return $attributes;
}