public static function BulkVariationsCreator::getSkuSettings in Commerce Bulk 8
Helper method to get variation sku field form display settings.
Parameters
\Drupal\commerce_product\Entity\ProductVariation $variation: The commerce product variation.
Return value
array The last three elements are only present on ProductVariationSkuWidget:
- "size": HTML size attribute value.
- "placeholder": HTML placeholder attribute value.
- "prefix": An optional prefix for the field value.
- "suffix": An optional suffix for the field value.
- "more_entropy": The length and therefore uniqueness of the field value.
Overrides BulkVariationsCreatorInterface::getSkuSettings
See also
\Drupal\commerce\Plugin\Field\FieldWidget\ProductVariationSkuWidget
\Drupal\Core\Field\Plugin\Field\FieldWidget\StringTextfieldWidget
5 calls to BulkVariationsCreator::getSkuSettings()
- BulkVariationsCreator::createAllIefFormVariations in src/
BulkVariationsCreator.php - An AJAX callback to create all possible variations.
- BulkVariationsCreator::createAllProductVariations in src/
BulkVariationsCreator.php - Creates all possible variations for commerce_product.
- BulkVariationsCreator::createProductVariation in src/
BulkVariationsCreator.php - Creates a variation for commerce_product.
- BulkVariationsCreator::duplicateAllProductVariations in src/
BulkVariationsCreator.php - BulkVariationsCreator::getAutoSku in src/
BulkVariationsCreator.php - Default value callback for the 'sku' base field definition.
File
- src/
BulkVariationsCreator.php, line 48
Class
- BulkVariationsCreator
- Default implementation of the BulkVariationsCreatorInterface.
Namespace
Drupal\commerce_bulkCode
public static function getSkuSettings(ProductVariation $variation) {
/** @var Drupal\commerce_product\Plugin\Field\FieldWidget\ProductVariationSkuWidget $widget */
/** @var Drupal\Core\Field\Plugin\Field\FieldWidget\StringTextfieldWidget $widget */
$widget = static::getSkuwidget($variation);
// If no one widget is enabled, then we need to asign uniqid() SKUs at the
// background to avoid having variations without SKU at all.
$default_sku_settings = [
'uniqid_enabled' => TRUE,
'more_entropy' => FALSE,
'prefix' => 'default_sku-',
'suffix' => '',
'maximum' => 500,
];
return $widget ? $widget
->getSettings() : $default_sku_settings;
}