public function ProductVariationStorage::loadBySku in Commerce Core 8.2
Loads the product variation for the given SKU.
Parameters
string $sku: The SKU.
Return value
\Drupal\commerce_product\Entity\ProductVariationInterface|null The product variation, or NULL if not found.
Overrides ProductVariationStorageInterface::loadBySku
File
- modules/
product/ src/ ProductVariationStorage.php, line 84
Class
- ProductVariationStorage
- Defines the product variation storage.
Namespace
Drupal\commerce_productCode
public function loadBySku($sku) {
$variations = $this
->loadByProperties([
'sku' => $sku,
]);
$variation = reset($variations);
return $variation ?: NULL;
}