function uc_product_feature_save in Ubercart 8.4
Same name and namespace in other branches
- 5 uc_product/uc_product.module \uc_product_feature_save()
- 6.2 uc_product/uc_product.module \uc_product_feature_save()
- 7.3 uc_product/uc_product.module \uc_product_feature_save()
Saves a product feature to a product node.
Parameters
array $data: An array consisting of the following keys:
- pfid: (optional) When editing an existing product feature, the numeric ID of the feature.
- nid: The numeric ID of the product node.
- fid: The string ID of the feature type.
- description: The string describing the feature for the overview table.
2 calls to uc_product_feature_save()
- FileFeatureForm::submitForm in uc_file/
src/ Form/ FileFeatureForm.php - Form submission handler.
- RoleFeatureForm::submitForm in uc_role/
src/ Form/ RoleFeatureForm.php - Form submission handler.
File
- uc_product/
uc_product.module, line 886 - The product module for Ubercart.
Code
function uc_product_feature_save(array &$data) {
$connection = \Drupal::database();
if (empty($data['pfid'])) {
unset($data['pfid']);
$data['pfid'] = $connection
->insert('uc_product_features')
->fields($data)
->execute();
\Drupal::messenger()
->addMessage(t('The product feature has been added.'));
}
else {
$connection
->merge('uc_product_features')
->key([
'pfid' => $data['pfid'],
])
->fields($data)
->execute();
\Drupal::messenger()
->addMessage(t('The product feature has been updated.'));
}
}