Last active
September 9, 2015 17:53
-
-
Save johannessteu/4650d891ce87c6180492 to your computer and use it in GitHub Desktop.
Productfilter with TypoScript2 and ES
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| GET /typo3cr-1441789525/Vendor-Foo:Product/_search | |
| { | |
| "query" : { | |
| "terms": | |
| { "sku": ["2239", "2235", " 2277", "2278", "2276", "2279"]} | |
| }, | |
| "facets": | |
| { | |
| "color": {"terms": {"field": "color", "all_terms": false}} | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Search Products, add a new term line for each filter | |
| GET /typo3cr-1441789525/Vendor-Foo/_search | |
| { | |
| "query" : { | |
| "filtered" : { | |
| "filter" : { | |
| "bool" : { | |
| "must" : [ | |
| {"terms" : {"sku": ["2239", "2235", " 2277", "2278"]}}, | |
| {"term" : {"__workspace": "live"}} | |
| ] | |
| } | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| prototype(Vendor.Foo:FilteredProductList) < prototype(TYPO3.Neos:Content) | |
| prototype(Vendor.Foo:FilteredProductList) { | |
| // Create Facet-Filter | |
| facets = TYPO3.TypoScript:RawArray { | |
| color = TYPO3.TypoScript:RawArray { | |
| terms = TYPO3.TypoScript:RawArray { | |
| field = "color" | |
| } | |
| } | |
| } | |
| // Create SearchFilter for products. Only show products that are configured | |
| searchFilter = TYPO3.TypoScript:RawArray { | |
| sku = ${String.split(q(node).property("products"), ",")} | |
| } | |
| // Add more Filter if set | |
| searchFilter.color = ${request.arguments.color} | |
| [email protected] = ${request.arguments.color != ""} | |
| // Create a query to get filtered products | |
| query = ${Search.query(site).nodeType("RaphaelGmbH.TraumgartenSite:Product").queryFilterMultiple(this.searchFilter, "must").limit(100)} | |
| // Fetch products | |
| products = ${this.query.execute()} | |
| // Note: .facet() is not implemented yet | |
| // you might want to recreate the query and remove the color filter and stuff | |
| filter = ${this.query.facet(this.facets)} | |
| @cache { | |
| mode = 'uncached' | |
| context { | |
| 1 = 'node' | |
| 2 = 'site' | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'RaphaelGmbH.TraumgartenSite:Product': | |
| properties: | |
| sku: | |
| type: string | |
| defaultValue: '' | |
| color: | |
| type: string | |
| defaultValue: '' | |
| ui: | |
| label: 'Farbe' | |
| inspector: | |
| group: 'attr' | |
| position: '20' | |
| search: | |
| elasticSearchMapping: | |
| type: "string" | |
| include_in_all: false | |
| index: 'not_analyzed' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The method .facets() ist not implemented yet.