From 64ecadce59462e7e220be21f0a06027e9c97536a Mon Sep 17 00:00:00 2001 From: paoloar77 Date: Thu, 16 Jan 2025 09:28:55 +0100 Subject: [PATCH] aa --- app/CustomFuncPao.php | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/app/CustomFuncPao.php b/app/CustomFuncPao.php index e05917e5..d0b6c39d 100644 --- a/app/CustomFuncPao.php +++ b/app/CustomFuncPao.php @@ -1144,20 +1144,24 @@ class ArticleFormatter private static function findInsideProduct($product, $field) { - // Se il campo specificato non è presente, restituisce null - if (!isset($product['meta_data']) || !is_array($product['meta_data'])) { - return null; - } - - // Cerca nella meta_data il valore corrispondente alla chiave specificata - foreach ($product['meta_data'] as $meta) { - if (isset($meta['key']) && $meta['key'] === $field) { - return $meta['value']; + try { + // Se il campo specificato non è presente, restituisce null + if (!isset($product->meta_data) || !is_array($product->meta_data)) { + return null; } - } - // Restituisce null se non trovato - return null; + // Cerca nella meta_data il valore corrispondente alla chiave specificata + foreach ($product->meta_data as $meta) { + if (isset($meta->key) && $meta->key === $field) { + return $meta->value; // Accedi come oggetto + } + } + + // Restituisce null se non trovato + return null; + } catch (Exception $e) { + echo $e->getMessage(); + } } }