Commit a51a3039 authored by jsacksick's avatar jsacksick
Browse files

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

parent 4fad495e
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment