docs: fix filters in meilisearch and algolia guides (#14098)
This commit is contained in:
@@ -540,9 +540,14 @@ You can now create the workflow that syncs the products to Algolia.
|
||||
To create the workflow, create the file `src/workflows/sync-products.ts` with the following content:
|
||||
|
||||
```ts title="src/workflows/sync-products.ts"
|
||||
import { createWorkflow, WorkflowResponse } from "@medusajs/framework/workflows-sdk"
|
||||
import {
|
||||
createWorkflow,
|
||||
transform,
|
||||
WorkflowResponse
|
||||
} from "@medusajs/framework/workflows-sdk"
|
||||
import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
|
||||
import { syncProductsStep, SyncProductsStepInput } from "./steps/sync-products"
|
||||
import { ProductStatus } from "@medusajs/framework/utils"
|
||||
|
||||
type SyncProductsWorkflowInput = {
|
||||
filters?: Record<string, unknown>
|
||||
@@ -553,6 +558,14 @@ type SyncProductsWorkflowInput = {
|
||||
export const syncProductsWorkflow = createWorkflow(
|
||||
"sync-products",
|
||||
({ filters, limit, offset }: SyncProductsWorkflowInput) => {
|
||||
const productFilters = transform({
|
||||
filters
|
||||
}, (data) => {
|
||||
return {
|
||||
status: ProductStatus.PUBLISHED,
|
||||
...data.filters
|
||||
}
|
||||
})
|
||||
const { data, metadata } = useQueryGraphStep({
|
||||
entity: "product",
|
||||
fields: [
|
||||
@@ -571,10 +584,7 @@ export const syncProductsWorkflow = createWorkflow(
|
||||
take: limit,
|
||||
skip: offset,
|
||||
},
|
||||
filters: {
|
||||
status: "published",
|
||||
...filters,
|
||||
},
|
||||
filters: productFilters,
|
||||
})
|
||||
|
||||
syncProductsStep({
|
||||
@@ -898,6 +908,7 @@ export default async function handleProductEvents({
|
||||
input: {
|
||||
filters: {
|
||||
id: data.id,
|
||||
status: "published",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -520,9 +520,14 @@ You can now create the workflow that syncs products to Meilisearch.
|
||||
To create the workflow, create the file `src/workflows/sync-products.ts` with the following content:
|
||||
|
||||
```ts title="src/workflows/sync-products.ts"
|
||||
import { createWorkflow, WorkflowResponse } from "@medusajs/framework/workflows-sdk"
|
||||
import {
|
||||
createWorkflow,
|
||||
transform,
|
||||
WorkflowResponse
|
||||
} from "@medusajs/framework/workflows-sdk"
|
||||
import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
|
||||
import { syncProductsStep, SyncProductsStepInput } from "./steps/sync-products"
|
||||
import { ProductStatus } from "@medusajs/framework/utils"
|
||||
|
||||
type SyncProductsWorkflowInput = {
|
||||
filters?: Record<string, unknown>
|
||||
@@ -533,6 +538,14 @@ type SyncProductsWorkflowInput = {
|
||||
export const syncProductsWorkflow = createWorkflow(
|
||||
"sync-products",
|
||||
({ filters, limit, offset }: SyncProductsWorkflowInput) => {
|
||||
const productFilters = transform({
|
||||
filters
|
||||
}, (data) => {
|
||||
return {
|
||||
status: ProductStatus.PUBLISHED,
|
||||
...data.filters
|
||||
}
|
||||
})
|
||||
const { data, metadata } = useQueryGraphStep({
|
||||
entity: "product",
|
||||
fields: [
|
||||
@@ -551,10 +564,7 @@ export const syncProductsWorkflow = createWorkflow(
|
||||
take: limit,
|
||||
skip: offset,
|
||||
},
|
||||
filters: {
|
||||
status: "published",
|
||||
...filters,
|
||||
},
|
||||
filters: productFilters,
|
||||
})
|
||||
|
||||
syncProductsStep({
|
||||
@@ -883,6 +893,7 @@ export default async function handleProductEvents({
|
||||
input: {
|
||||
filters: {
|
||||
id: data.id,
|
||||
status: "published",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user