@graphcommerce/docs 9.0.0-canary.83 → 9.0.0-canary.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 9.0.0-canary.85
4
+
5
+ ## 9.0.0-canary.84
6
+
3
7
  ## 9.0.0-canary.83
4
8
 
5
9
  ## 9.0.0-canary.82
@@ -1,31 +1,34 @@
1
- # Algolia Magento 2
1
+ # Implementing Advanced Search with Algolia in GraphCommerce
2
2
 
3
- An implementation of Algolia through the GraphQL Mesh.
3
+ The need for fast, relevant, and personalized search experiences has become
4
+ paramount. GraphCommerce, This integration offers developers a robust solution
5
+ to enhance search capabilities while maintaining the flexibility and performance
6
+ that GraphCommerce is known for.
4
7
 
5
- ## Prerequisites
8
+ In this article, we'll dive deep into the technical aspects of implementing
9
+ Algolia in GraphCommerce, exploring the architecture, key components, and best
10
+ practices for leveraging this powerful integration.
6
11
 
7
- Make sure the Magento 2 module is correctly installed and working.
12
+ The Algolia integration in GraphCommerce is designed with a clear separation
13
+ between the GraphQL layer and the frontend implementation. This architecture
14
+ allows for seamless integration with existing GraphCommerce setups while
15
+ providing the flexibility to customize and extend functionality as needed.
8
16
 
9
- ## Installation
17
+ The is composed of five packages:
10
18
 
11
- 1. Find current version of your `@graphcommerce/next-ui` in your package.json.
12
- 2. `yarn add @graphcommerce/address-fields-nl@9.0.0` (replace 9.0.0 with the
13
- version of the step above)
14
- 3. Configure the following ([configuration values](./Config.graphqls)) in your
15
- graphcommerce.config.js:
19
+ - `@graphcommerce/algolia-products`
20
+ - `@graphcommerce/algolia-categories`
21
+ - `@graphcommerce/algolia-insights`
22
+ - `@graphcommerce/algolia-personalization`
23
+ - `@graphcommerce/algolia-recommend`
16
24
 
17
- ```js
18
- const config = {
19
- algolia: {
20
- applicationId: 'your-algolia-application-id', // Stores > Configuration > Algolia Search > Credentials and Basic Setup > Application ID
21
- indexNamePrefix: 'default_', // Stores > Configuration > Algolia Search > Credentials and Basic Setup > Index name prefix
22
- searchOnlyApiKey: 'blabla', // Stores > Configuration > Algolia Search > Credentials and Basic Setup > Search-only (public) API key
23
- catalogEnabled: false, // start with search and if everything works as expected, you can move on to the catalog.
24
- },
25
- }
26
- ```
25
+ ## Installation and configuration of Algolia for GraphCommerce
27
26
 
28
- ### Configuration
27
+ ### Preparation
28
+
29
+ To integrate Magento's product catalog with GraphCommerce, you need to set up
30
+ your Algolia indexes. This is typically done using the Magento 2 Algolia module,
31
+ which handles the synchronization of product and category data.
29
32
 
30
33
  1. Setup the fields that you want to index in algolia
31
34
  `Stores > configuration > Algolia Search > Products > Products`
@@ -38,11 +41,256 @@ Make sure the Magento 2 module is correctly installed and working.
38
41
  4. To configure sorting options, enable Virtual Replica's.
39
42
  `Stores > Configuration > Algolia Search > Instant Search Results Page > Use Virtual Replica`
40
43
 
44
+ ### @graphcommerce/algolia-products
45
+
46
+ After this package is installed and configured the search is automatically
47
+ replaced by Algolia's search.
48
+
49
+ This package is responsible for integrating Algolia's search functionality into
50
+ GraphCommerce's GraphQL layer. It includes several key components:
51
+
52
+ - **Search Result Mapping**: Converts Algolia search hits to Magento-compatible
53
+ product objects.
54
+ - **Facet Handling**: Transforms Algolia facets into Magento-style aggregations
55
+ for consistent filtering.
56
+ - **Query Input Preparation**: Prepares search inputs to align with Algolia's
57
+ query structure.
58
+
59
+ Find current version of your `@graphcommerce/next-ui` in your package.json. And
60
+ run `yarn add @graphcommerce/algolia-products@9.0.0` (replace 9.0.0 with the
61
+ same version as the `@graphcommerce/next-ui`)
62
+
63
+ To enable Algolia in your GraphCommerce project, you'll need to add the
64
+ necessary configuration to your `graphcommerce.config.js` file:
65
+
66
+ ```ts
67
+ module.exports = {
68
+ // Other configuration...
69
+ algolia: {
70
+ // Configure your Algolia application ID.
71
+ // Stores > Configuration > Algolia Search > Credentials and Basic Setup > Application ID
72
+ applicationId: 'SAME_AS_MAGENTO',
73
+
74
+ // Configure your Algolia Search Only API Key.
75
+ // Stores > Configuration > Algolia Search > Credentials and Basic Setup > Search-only (public) API key
76
+ searchOnlyApiKey: 'SAME_AS_MAGENTO',
77
+
78
+ // Stores > Configuration > Algolia Search > Credentials and Basic Setup > Index name prefix
79
+ indexNamePrefix: 'SAME_AS_MAGENTO',
80
+
81
+ // By default the catalog will not use algolia. Set this to true to enable Algolia for the catalog.
82
+ catalogEnabled: true,
83
+
84
+ // Enable Algolia customer group pricing.
85
+ // Please be aware that personalization needs to be enabled as well to make this work.
86
+ customerGroupPricingEnabled: true,
87
+ },
88
+ }
89
+ ```
90
+
91
+ When writing your own product queries, you can set the engine to `algolia` to
92
+ use Algolia's search.
93
+
94
+ ```graphql
95
+ query AlgoliaProducts {
96
+ products(filter: { engine: { eq: "algolia" } }) {
97
+ items {
98
+ name
99
+ }
100
+ }
101
+ }
102
+ ```
103
+
104
+ See the
105
+ [algoliaHitToMagentoProduct](https://github.com/graphcommerce-org/graphcommerce/blob/main/packages/algolia-products/mesh/algoliaHitToMagentoProduct.ts)
106
+ for all the fields that are returned.
107
+
108
+ ### @graphcommerce/algolia-categories
109
+
110
+ This package is responsible for integrating Algolia's category search
111
+ functionality into GraphCommerce's GraphQL layer.
112
+
113
+ We currenly do not support replacing the whole category tree with Algolia's
114
+ categories, because only a reduced set of fields are indexed to algolia.
115
+
116
+ When writing your own category queries, you can set the engine to `algolia` to
117
+ use Algolia's search.
118
+
119
+ ```graphql
120
+ query AlgoliaCategories {
121
+ categories(filters: { engine: { eq: "algolia" } }) {
122
+ items {
123
+ name
124
+ breadcrumbs {
125
+ category_name
126
+ }
127
+ }
128
+ }
129
+ }
130
+ ```
131
+
132
+ See the
133
+ [algoliaHitToMagentoCategory](https://github.com/graphcommerce-org/graphcommerce/blob/main/packages/algolia-categories/mesh/algoliaHitToMagentoCategory.ts)
134
+ for all the fields that are returned.
135
+
136
+ ### @graphcommerce/algolia-insights
137
+
138
+ This package implements Algolia's insights features, which are used to track
139
+ user interactions and improve search relevance. These events are crucial for
140
+ enabling features like NeuralSearch, Dynamic Re-Ranking, Query Categorization,
141
+ Analytics, A/B Testing, Recommend, and Personalization.
142
+
143
+ 1. When installed the feature is automatically enabled.
144
+ 2. Browse the site and verify that events are being logged in the Algolia
145
+ dashboard. You can check this in the Event Debugger:
146
+ `Data Sources > Events > Debugger`.
147
+
148
+ The events as described in
149
+ [Algolia's event types page](https://www.algolia.com/doc/guides/sending-events/concepts/event-types)
150
+ are sent to Algolia from the codebase.
151
+
152
+ The event flow implemented is as follows:
153
+
154
+ 1. When a user sees a product on the screen (IntersectionObserver) the
155
+ `viewedObjectIDs`/`viewedObjectIDsAfterSearch` is send.
156
+ 2. When a user views a list of products the `viewedFilters`/`clickedFilters` are
157
+ send.
158
+ 3. When a user clicks on a product the
159
+ `clickedObjectIDs`/`clickedObjectIDsAfterSearch` is send.
160
+ 4. When a user adds a product to the cart the
161
+ `addedToCartObjectIDs`/`addedToCartObjectIDsAfterSearch` is send. We
162
+ automatically track where each item in the cart originated form. We track
163
+ every item in the cart and match them to the original query that was used to
164
+ find them.
165
+ 5. When a user purchases a product the
166
+ `purchasedObjectIDs`/`purchasedObjectIDsAfterSearch` is send. We
167
+ automatically track where each item in the purchase originated form. We track
168
+ every item in the purchase and match them to the original query that was used
169
+ to find them.
170
+
171
+ Note: The `convertedObjectIds`/`convertedObjectIDsAfterSearch` are not
172
+ implemented, they are a simplified version of the
173
+ `addedToCartObjectIDs`/`addedToCartObjectIDsAfterSearch`
174
+
175
+ The `useSendAlgoliaEvent` hook in `@graphcommerce/algolia-insights` is
176
+ responsible for sending these events to Algolia.
177
+
178
+ ### @graphcommerce/algolia-personalization
179
+
180
+ This package requires insights to be sent to Algolia for them to be able to
181
+ create personalized queries. Once you've collected several events, set up
182
+ personalization strategies in the Algolia dashboard under
183
+ `Enhance > Personalization`.
184
+
185
+ This package implements Algolia's personalization features, including:
186
+ Personalized search results and User token management for consistent
187
+ identification
188
+
189
+ Note: This package is optional because this will increase the amount of API
190
+ calls send to Algolia which can increase your costs when viewing lists of
191
+ products that otherwise are static like related products, category queries etc.
192
+
193
+ ### @graphcommerce/algolia-recommend
194
+
195
+ This package requires insights to be sent to Algolia for them to be able to
196
+ create recommendations. Once you've collected several events, set up
197
+ recommendation strategies in the Algolia dashboard under `Recommend > Models`.
198
+
199
+ This package implements Algolia's recommendation features, including:
200
+
201
+ - Related products
202
+ - Frequently bought together
203
+ - Similar looking items
204
+
205
+ The recommend package can replace various sections of Magento's default fields.
206
+ So this can be a drop-in replacement. You can configure which fields to replace
207
+ by updating your `graphcommerce.config.js`:
208
+
209
+ ```ts
210
+ module.exports = {
211
+ algolia: {
212
+ lookingSimilar: 'UPSELL_PRODUCTS',
213
+ frequentlyBoughtTogether: 'CROSSSELL_PRODUCTS',
214
+ relatedProducts: 'RELATED_PRODUCTS',
215
+ },
216
+ }
217
+ ```
218
+
219
+ Besides this the features are also available as separate fields on products:
220
+
221
+ ```graphql
222
+ query AlgoliaProducts {
223
+ products(filter: { engine: { eq: "algolia" } }) {
224
+ items {
225
+ name
226
+ algolia_looking_similar {
227
+ name
228
+ }
229
+ algolia_related_products {
230
+ name
231
+ }
232
+ algolia_frequently_bought_together {
233
+ name
234
+ }
235
+ }
236
+ }
237
+ }
238
+ ```
239
+
240
+ ## Multi-store and Multi-language Support
241
+
242
+ The Algolia integration in GraphCommerce supports multi-store and multi-language
243
+ setups out of the box. It uses the indexes created by the Magento 2 Algolia
244
+ module.
245
+
246
+ ## Additional Configuration
247
+
248
+ ### Sorting Options
249
+
250
+ To configure sorting options for your Algolia-powered search, you need to enable
251
+ Virtual Replicas in your Magento 2 Algolia module configuration:
252
+
253
+ 1. Navigate to
254
+ `Stores > Configuration > Algolia Search > Instant Search Results Page`
255
+ 2. Enable the "Use Virtual Replica" option
256
+
257
+ This allows you to define different sorting options, each of which will be
258
+ treated as a separate (virtual) index in Algolia.
259
+
260
+ ### Customer Group Pricing
261
+
262
+ To enable customer group pricing, make sure customers groups prices are mapped
263
+ to algolia.
264
+ `Stores > Configuration > Algolia Search > Advanced > Enable Customer Groups`.
265
+
266
+ ⚠️ Warning: Catalog price rules for a specific customer group do not seem to be
267
+ indexed.It seems only: `[Product] > Advanced Pricing > Customer Group Price`
268
+ gets indexed.
269
+
270
+ Note: The GraphQL API does not expose the customer group_id by default. We're
271
+ doing an additional REST API call to get the value. This means a somewhat slower
272
+ (few hundred ms) when the Customer is loaded.
273
+
41
274
  ### Customization
42
275
 
43
- Customise the code by creating plugins on the functions you want to adjust
276
+ By default `algoliaFacetsToAggregations` and `algoliaHitToMagentoProduct` are
277
+ split into it's own functions so plugins can be easily written.
278
+
279
+ ## Conclusion
280
+
281
+ The Algolia integration in GraphCommerce offers a powerful toolset for
282
+ implementing advanced search and discovery features in your e-commerce
283
+ application. By leveraging the separation of concerns between the GraphQL layer
284
+ and frontend implementation, you can create a flexible, performant, and
285
+ feature-rich search experience.
286
+
287
+ As you implement and customize the Algolia integration, remember to focus on
288
+ performance, user experience, and data privacy. Regularly analyze search
289
+ analytics and user behavior to continually refine and improve your search
290
+ implementation.
44
291
 
45
- ## Algolia for Catalog
292
+ For more information and detailed documentation, visit the GraphCommerce GitHub
293
+ repository and Algolia's developer documentation. Happy coding!
46
294
 
47
- Sorting is defined by Algolia and can not be configured per category as each
48
- sorting option is a separate (virtual) index.
295
+ TODO: INSERT GRAPHIC - Diagram illustrating the architecture of Algolia
296
+ integration in GraphCommerce
package/package.json CHANGED
@@ -2,10 +2,10 @@
2
2
  "name": "@graphcommerce/docs",
3
3
  "homepage": "https://www.graphcommerce.org/docs",
4
4
  "repository": "github:graphcommerce-org/graphcommerce/docs",
5
- "version": "9.0.0-canary.83",
5
+ "version": "9.0.0-canary.85",
6
6
  "sideEffects": true,
7
7
  "peerDependencies": {
8
- "@graphcommerce/prettier-config-pwa": "^9.0.0-canary.83"
8
+ "@graphcommerce/prettier-config-pwa": "^9.0.0-canary.85"
9
9
  },
10
10
  "prettier": "@graphcommerce/prettier-config-pwa"
11
11
  }