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 [];
}
Comments
Comment #3
jsacksick commentedPushed a fix, thanks for the report.