From 2c6bde89cd24b5c98e3d8262873571f79f1cb650 Mon Sep 17 00:00:00 2001 From: Iago Date: Mon, 11 Mar 2024 13:52:43 -0300 Subject: [PATCH 1/3] feat: add groupBy prop in recommendation shelf --- react/RelatedProducts.js | 19 ++++++++++++++++++- react/queries/productRecommendations.gql | 3 ++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/react/RelatedProducts.js b/react/RelatedProducts.js index a3b604b..c888f4a 100644 --- a/react/RelatedProducts.js +++ b/react/RelatedProducts.js @@ -32,6 +32,7 @@ const fixRecommendation = recommendation => { const RelatedProducts = ({ productQuery, productList, + groupBy, recommendation: cmsRecommendation, trackingId: rawTrackingId, hideOutOfStockItems, @@ -64,8 +65,9 @@ const RelatedProducts = ({ return { identifier: { field: 'id', value: productId }, type: recommendation, + groupBy } - }, [productId, recommendation]) + }, [productId, recommendation, groupBy]) if (!productId) { return null @@ -128,6 +130,7 @@ RelatedProducts.defaultProps = { ...ProductList.defaultProps, titleText: 'Related Products', }, + groupBy: 'PRODUCT', hideOutOfStockItems: false, } @@ -158,6 +161,20 @@ RelatedProducts.schema = { 'admin/editor.relatedProducts.suggestions', ], }, + groupBy:{ + title: 'admin/editor.relatedProducts.groupBy.title', + description: 'admin/editor.relatedProducts.groupBy.description', + type: 'string', + default: RelatedProducts.defaultProps.groupBy, + enum: [ + 'PRODUCT', + 'NONE', + ], + enumNames: [ + 'admin/editor.relatedProducts.groupBy.product', + 'admin/editor.relatedProducts.groupBy.none' + ], + }, productList: ProductList.schema, hideOutOfStockItems: { title: 'admin/editor.shelf.hideOutOfStockItems', diff --git a/react/queries/productRecommendations.gql b/react/queries/productRecommendations.gql index 7db5878..7c39344 100644 --- a/react/queries/productRecommendations.gql +++ b/react/queries/productRecommendations.gql @@ -1,8 +1,9 @@ query ProductRecommendations( $identifier: ProductUniqueIdentifier $type: CrossSelingInputEnum + $groupBy: CrossSelingGroupByEnum ) { - productRecommendations(identifier: $identifier, type: $type) + productRecommendations(identifier: $identifier, type: $type, groupBy: $groupBy) @context(provider: "vtex.search-graphql") { cacheId productId From d9efe57749425e7c7f7b693d53d8b1ff3f9c8994 Mon Sep 17 00:00:00 2001 From: Iago Date: Mon, 11 Mar 2024 14:19:45 -0300 Subject: [PATCH 2/3] feat: add groupBy prop in recommendation shelf --- CHANGELOG.md | 4 ++++ docs/README.md | 1 + messages/context.json | 4 ++++ messages/en.json | 4 ++++ messages/es.json | 4 ++++ messages/pt.json | 4 ++++ react/RelatedProducts.js | 9 +++------ 7 files changed, 24 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d468d3d..75ccfe7 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 + +- GroupBy prop in `shelf.relatedProducts` + ## [1.47.4] - 2023-06-30 ### Fixed diff --git a/docs/README.md b/docs/README.md index a45478b..83a0b71 100644 --- a/docs/README.md +++ b/docs/README.md @@ -61,6 +61,7 @@ Now, you can use all the blocks exported by the `shelf` app. See the full list b | Prop name | Type | Description | Default value | | - | - | - | - | | `recommendation` | `enum` | Type of recommendations that will be displayed on the shelf. Possible values: `similars`, `suggestions`, and `accessories` (these depend on the product information given in the Admin Catalog); and `view`, `buy`, and `viewandBought` (these are automatically generated according to the activity of the store). | `similars` | +| `groupBy` | `enum` | Defines if you are ot nog going to group your recommendations by: `PRODUCT` (only display individual products and not SKUs, limited by 12 products) or `NONE` (if you want to display all registered SKUs, limited by 50 products). | `PRODUCT` | | `hideOutOfStockItems` | `boolean` | Whether out of stock items should be hidden: (`true`) or (`false`). | `false` | | `productList` | `ProductListSchema` | Product list schema. See `ProductListSchema`. | - | diff --git a/messages/context.json b/messages/context.json index c986d43..0e8df3a 100644 --- a/messages/context.json +++ b/messages/context.json @@ -50,6 +50,10 @@ "admin/editor.relatedProducts.accessories": "admin/editor.relatedProducts.accessories", "admin/editor.relatedProducts.viewAndBought": "admin/editor.relatedProducts.viewAndBought", "admin/editor.relatedProducts.suggestions": "admin/editor.relatedProducts.suggestions", + "admin/editor.relatedProducts.groupBy.title": "admin/editor.relatedProducts.groupBy.title", + "admin/editor.relatedProducts.groupBy.description": "admin/editor.relatedProducts.groupBy.description", + "admin/editor.relatedProducts.groupBy.product": "admin/editor.relatedProducts.groupBy.product", + "admin/editor.relatedProducts.groupBy.none": "admin/editor.relatedProducts.groupBy.none", "store/shelf.title": "store/shelf.title", "admin/editor.tabbed-shelf.title": "Component title", "admin/editor.tabbed-shelf.description": "Component description", diff --git a/messages/en.json b/messages/en.json index 4d90df3..2533f7e 100644 --- a/messages/en.json +++ b/messages/en.json @@ -50,6 +50,10 @@ "admin/editor.relatedProducts.accessories": "Accessories products", "admin/editor.relatedProducts.viewAndBought": "Who saw this, also bought...", "admin/editor.relatedProducts.suggestions": "Suggestions", + "admin/editor.relatedProducts.groupBy.title": "Group by", + "admin/editor.relatedProducts.groupBy.description": "Group recommendation list", + "admin/editor.relatedProducts.groupBy.product": "Products", + "admin/editor.relatedProducts.groupBy.none": "Do not group", "store/shelf.title": "Best Products", "admin/editor.tabbed-shelf.title": "Tabbed Shelf", "admin/editor.tabbed-shelf.description": "Tabbed Shelf featured product module", diff --git a/messages/es.json b/messages/es.json index b7bc682..f23c0d5 100644 --- a/messages/es.json +++ b/messages/es.json @@ -50,6 +50,10 @@ "admin/editor.relatedProducts.accessories": "Productos de accesorios", "admin/editor.relatedProducts.viewAndBought": "Quien vio esto, también compró ...", "admin/editor.relatedProducts.suggestions": "Sugerencias", + "admin/editor.relatedProducts.groupBy.title": "Agrupar", + "admin/editor.relatedProducts.groupBy.description": "Agrupar lista de recomendaciones", + "admin/editor.relatedProducts.groupBy.product": "Productos", + "admin/editor.relatedProducts.groupBy.none": "No agrupar", "store/shelf.title": "Mejores Productos", "admin/editor.shelf-properties.title.title": "Título", "admin/editor.shelf-properties.title.description": "Título del estante", diff --git a/messages/pt.json b/messages/pt.json index f15e448..c9b36d6 100644 --- a/messages/pt.json +++ b/messages/pt.json @@ -50,6 +50,10 @@ "admin/editor.relatedProducts.accessories": "Produtos de acessórios", "admin/editor.relatedProducts.viewAndBought": "Quem viu isto, comprou também...", "admin/editor.relatedProducts.suggestions": "Sugestões", + "admin/editor.relatedProducts.groupBy.title": "Agrupar por", + "admin/editor.relatedProducts.groupBy.description": "Agrupar listas de recomendações", + "admin/editor.relatedProducts.groupBy.product": "Produtos", + "admin/editor.relatedProducts.groupBy.none": "Não agrupar", "store/shelf.title": "Melhores Produtos", "admin/editor.shelf-properties.title.title": "Título", "admin/editor.shelf-properties.title.description": "Título da vitrine", diff --git a/react/RelatedProducts.js b/react/RelatedProducts.js index c888f4a..d1e6e8e 100644 --- a/react/RelatedProducts.js +++ b/react/RelatedProducts.js @@ -65,7 +65,7 @@ const RelatedProducts = ({ return { identifier: { field: 'id', value: productId }, type: recommendation, - groupBy + groupBy, } }, [productId, recommendation, groupBy]) @@ -161,15 +161,12 @@ RelatedProducts.schema = { 'admin/editor.relatedProducts.suggestions', ], }, - groupBy:{ + groupBy: { title: 'admin/editor.relatedProducts.groupBy.title', description: 'admin/editor.relatedProducts.groupBy.description', type: 'string', default: RelatedProducts.defaultProps.groupBy, - enum: [ - 'PRODUCT', - 'NONE', - ], + enum: ['PRODUCT','NONE'], enumNames: [ 'admin/editor.relatedProducts.groupBy.product', 'admin/editor.relatedProducts.groupBy.none' From 08d86bc23a25636ba6dd758b38df6c37988aeb32 Mon Sep 17 00:00:00 2001 From: Iago Date: Mon, 11 Mar 2024 14:23:37 -0300 Subject: [PATCH 3/3] feat: add groupBy prop in recommendation shelf --- react/RelatedProducts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/react/RelatedProducts.js b/react/RelatedProducts.js index d1e6e8e..49a803c 100644 --- a/react/RelatedProducts.js +++ b/react/RelatedProducts.js @@ -166,10 +166,10 @@ RelatedProducts.schema = { description: 'admin/editor.relatedProducts.groupBy.description', type: 'string', default: RelatedProducts.defaultProps.groupBy, - enum: ['PRODUCT','NONE'], + enum: ['PRODUCT', 'NONE'], enumNames: [ 'admin/editor.relatedProducts.groupBy.product', - 'admin/editor.relatedProducts.groupBy.none' + 'admin/editor.relatedProducts.groupBy.none', ], }, productList: ProductList.schema,