Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(search): add actions to search #488

Merged
merged 2 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog

## v3.8.1 [upcoming]
## v3.9.0 [upcoming]

**search**

* Introduce an Action to search result to advise the frontend to perform an action for that search different from displaying the result page.
The action model is completely open to anything, but the most common use case is to redirect certain searches directly to product detail pages or special brand landing pages.

**product**
* Add to cart of bundle products now only fails for missing required bundle choices. As prior passing all choices with qty of zero have been required. Now optional choices with qty of zero can be omitted.
Expand Down
3 changes: 3 additions & 0 deletions product/application/searchService.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type (
Facets searchdomain.FacetCollection
PaginationInfo utils.PaginationInfo
Promotions []searchdomain.Promotion
Actions []searchdomain.Action
}
)

Expand Down Expand Up @@ -103,6 +104,7 @@ func (s *ProductSearchService) Find(ctx context.Context, searchRequest *applicat
Products: result.Hits,
PaginationInfo: paginationInfo,
Promotions: result.Promotions,
Actions: result.Actions,
}, nil
}

Expand Down Expand Up @@ -154,5 +156,6 @@ func (s *ProductSearchService) FindBy(ctx context.Context, attributeCode string,
Products: result.Hits,
PaginationInfo: paginationInfo,
Promotions: result.Result.Promotions,
Actions: result.Actions,
}, nil
}
4 changes: 4 additions & 0 deletions product/interfaces/graphql/dto.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ func (obj *SearchResultDTO) Suggestions() []searchdomain.Suggestion {
return obj.result.Suggestions
}

func (obj *SearchResultDTO) Actions() []searchdomain.Action {
return obj.result.Actions
}

// Products get products
func (obj *SearchResultDTO) Products() []graphqlProductDto.Product {
products := make([]graphqlProductDto.Product, 0, len(obj.result.Products))
Expand Down
1 change: 1 addition & 0 deletions product/interfaces/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ type Commerce_Product_SearchResult {
searchMeta: Commerce_Search_Meta!
hasSelectedFacet: Boolean!
promotion: Commerce_Search_Promotion
actions: [Commerce_Search_Action!]
}

type Commerce_Product_Badges {
Expand Down
8 changes: 8 additions & 0 deletions search/domain/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ type (
Suggestion []Suggestion
Facets FacetCollection
Promotions []Promotion
Actions []Action
}

// Action might be considered on the frontend to be taken depending on search results
Action struct {
Type string
Content string
AdditionalAttributes map[string]interface{}
}

// SearchMeta data
Expand Down
5 changes: 5 additions & 0 deletions search/interfaces/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ type Commerce_Search_Suggestion {
highlight: String!
}

type Commerce_Search_Action {
type: String!
content: String!
}

type Commerce_Search_Promotion {
title: String!
content: String!
Expand Down
1 change: 1 addition & 0 deletions search/interfaces/graphql/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func (*Service) Types(types *graphql.Types) {
types.Map("Commerce_Search_Request", searchdto.CommerceSearchRequest{})
types.Map("Commerce_Search_KeyValueFilter", searchdto.CommerceSearchKeyValueFilter{})
types.Map("Commerce_Search_Suggestion", domain.Suggestion{})
types.Map("Commerce_Search_Action", domain.Action{})
types.Map("Commerce_Search_Result", application.SearchResult{})
types.Map("Commerce_Search_SortOption", searchdto.CommerceSearchSortOption{})
types.Map("Commerce_Search_Facet", new(searchdto.CommerceSearchFacet))
Expand Down
Loading
Loading