Skip to content

Commit

Permalink
Merge pull request #36 from Reviewscouk/fix/undefined-array-index
Browse files Browse the repository at this point in the history
fix accessing undefined array index (with fallback)
  • Loading branch information
rahaddon authored Oct 4, 2022
2 parents c1ca7be + 6f8edf4 commit 8d154a7
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 8d154a7

Please sign in to comment.