Skip to content
Snippets Groups Projects
Commit a51a3039 authored by Jonathan Sacksick's avatar Jonathan Sacksick
Browse files

Ensure the title generation doesn't fail if the product cannot be loaded.

parent 4fad495e
Branches 8.x-2.x
Tags 8.x-2.15
7 merge requests!418Issue #3511232 by ccjjmartin: Fix add to cart dropdown when only one non-default variation type is provided,!379Issue #3491248 Validation is breaking the amount number format decimal point,!375Issue #3413020 by czigor: Using a translatable string as a category for field...,!357Issue #2914933: Add service tags to order-related interfaces,!344Resolve #3107602 "Product attributes do not update visually when switching variations",!343Resolve #3107602 "Product attributes do not update visually when switching variations",!342Issue #3476581 by josephr5000: add OrderItemLabelEvent
......@@ -419,12 +419,13 @@ class ProductVariation extends CommerceContentEntityBase implements ProductVaria
* The generated value.
*/
protected function generateTitle() {
if (!$this->getProductId()) {
$product = $this->getProduct();
if (!$product) {
// Title generation is not possible before the parent product is known.
return '';
}
$product_title = $this->getProduct()->getTitle();
$product_title = $product->getTitle();
if ($attribute_values = $this->getAttributeValues()) {
$attribute_labels = EntityHelper::extractLabels($attribute_values);
$title = $product_title . ' - ' . implode(', ', $attribute_labels);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment