Skip to content

Commit

Permalink
fix accessing undefined array index (with fallback)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-Bromley committed Oct 3, 2022
1 parent c1ca7be commit 6f8edf4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Block/Richsnippet.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@ public function autoRichSnippet()
if ($current_product && $product_enabled) {

$sku = $this->dataHelper->getProductSkus($current_product);

$productAvailability = $this->availability();
if (array_key_exists('is_in_stock', $current_product->getData('quantity_and_stock_status'))) {
$productAvailability = $this->availability($current_product->getData('quantity_and_stock_status')['is_in_stock']);
}

$product = [
'availability' => $this->availability($current_product->getData('quantity_and_stock_status')['is_in_stock']),
'availability' => $productAvailability,
'price' => $current_product->getFinalPrice(),
'url' => $current_product->getProductUrl(),
'description' => $current_product->getMetaDescription(),
Expand Down

0 comments on commit 6f8edf4

Please sign in to comment.