Commerce Product Add-on with layout builder gives error

Created on 8 May 2024, 7 months ago
Updated 19 September 2024, 2 months ago

When you use the commerce product add-on with layout builder then on the manage default layout tab there is no product id available so it gives an error.

Solution:
We need to check the product id is not null or we can use is_object after the product load call and return [] so no error shown

$product = $this->entityTypeManager->getStorage('commerce_product')->load($product_id);
+if(!is_object($product)) {
+ return [];
+}
$default_variation = $product->getDefaultVariation();
if (!$default_variation) {
return [];
}

🐛 Bug report
Status

Fixed

Version

1.3

Component

Code

Created by

🇮🇳India 21kPiyush

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024