From abc048adf0d8dc13451de1342f393c1ee5283525 Mon Sep 17 00:00:00 2001 From: "Tanta Melgar, Eli Antonio ( Externos - Baufest S.A.)" Date: Thu, 18 Sep 2025 10:06:16 -0500 Subject: [PATCH] feat: add disableProduct appSetting to disable Product JSON-LD enrichment --- CHANGELOG.md | 4 ++++ manifest.json | 6 ++++++ react/Product.js | 5 +++++ react/hooks/useAppSettings.ts | 7 ++++++- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0293566..bd97fcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Added + +- Creation of a new appSettings (false by default) `disableProduct` - used to disable the product enrichment in Product structured data (JSON-LD). + ## [0.16.0] - 2025-07-18 ## [0.15.0] - 2025-04-28 diff --git a/manifest.json b/manifest.json index 1fd2c61..944f2cb 100644 --- a/manifest.json +++ b/manifest.json @@ -80,6 +80,12 @@ ], "default": "ean", "description": "Set the value used for GTIN" + }, + "disableProduct": { + "title": "Disable Product", + "type": "boolean", + "default": false, + "description": "Disable product" } } }, diff --git a/react/Product.js b/react/Product.js index b5415e5..a7d3364 100644 --- a/react/Product.js +++ b/react/Product.js @@ -260,8 +260,13 @@ function StructuredData({ product, selectedItem }) { useImagesArray, disableAggregateOffer, gtinValue, + disableProduct } = useAppSettings() + if (disableProduct) { + return null; + } + const productLD = parseToJsonLD({ product, selectedItem, diff --git a/react/hooks/useAppSettings.ts b/react/hooks/useAppSettings.ts index ae301d4..79c6494 100644 --- a/react/hooks/useAppSettings.ts +++ b/react/hooks/useAppSettings.ts @@ -9,6 +9,7 @@ const DEFAULT_USE_SELLER_DEFAULT = false const DEFAULT_USE_IMAGES_ARRAY = false const DEFAULT_DISABLE_AGGREGATE_OFFER = false const DEFAULT_GTIN_VALUE = 'itemId' +const DEFAULT_DISABLE_PRODUCT = false interface Settings { disableOffers: boolean @@ -17,7 +18,8 @@ interface Settings { useSellerDefault: boolean useImagesArray: boolean disableAggregateOffer: boolean - gtinValue?: string + gtinValue?: string, + disableProduct?: boolean } const useAppSettings = (): Settings => { @@ -32,6 +34,7 @@ const useAppSettings = (): Settings => { useImagesArray, disableAggregateOffer, gtinValue, + disableProduct } = JSON.parse(data.publicSettingsForApp.message) return { @@ -43,6 +46,7 @@ const useAppSettings = (): Settings => { disableAggregateOffer: disableAggregateOffer || DEFAULT_DISABLE_AGGREGATE_OFFER, gtinValue: gtinValue || DEFAULT_GTIN_VALUE, + disableProduct: disableProduct || DEFAULT_DISABLE_PRODUCT, } } @@ -54,6 +58,7 @@ const useAppSettings = (): Settings => { useImagesArray: DEFAULT_USE_IMAGES_ARRAY, disableAggregateOffer: DEFAULT_DISABLE_AGGREGATE_OFFER, gtinValue: DEFAULT_GTIN_VALUE, + disableProduct: DEFAULT_DISABLE_PRODUCT, } }