Skip to content

Commit

Permalink
fixes based on feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
shahednasser committed Sep 26, 2022
1 parent 55486fe commit 6c6dfcd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
18 changes: 12 additions & 6 deletions docs/content/advanced/backend/batch-jobs/customize-import.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ The batch job strategy class must extend the `AbstractBatchJobStrategy` class wh

For example, you can define the following class in the file you created:

```tsx
```typescript
import { AbstractBatchJobStrategy, BatchJobService } from '@medusajs/medusa'
import { EntityManager } from 'typeorm'

class ImportStrategy extends AbstractBatchJobStrategy {
class MyImportStrategy extends AbstractBatchJobStrategy {
protected batchJobService_: BatchJobService
protected manager_: EntityManager
protected transactionManager_: EntityManager
Expand All @@ -57,9 +57,15 @@ class ImportStrategy extends AbstractBatchJobStrategy {
}
}

export default ImportStrategy
export default MyImportStrategy
```

:::note

This is the base implementation of a batch job strategy. You can learn about all the different methods and properties in [this documentation](./create.md#3-define-required-properties).

:::

### 3. Set the batchType Property

Every batch job strategy class must have the static property `batchType` defined. It determines the type of batch job this strategy handles.
Expand All @@ -68,8 +74,8 @@ Since only one batch job strategy can handle a batch job type, you can overwrite

So, for example, to overwrite the product import strategy set the `batchType` property in your strategy to `product-import`:

```tsx
class ImportStrategy extends AbstractBatchJobStrategy {
```typescript
class MyImportStrategy extends AbstractBatchJobStrategy {
static batchType = 'product-import'
//...
}
Expand All @@ -85,7 +91,7 @@ Refer to the [Create a Batch Job documentation](./create.md#3-define-required-pr

Before you can test out your batch job strategy, you must run the `build` command:

```tsx
```bash npm2yarn
npm run build
```

Expand Down
2 changes: 1 addition & 1 deletion docs/styles/docs/Npm2Yarn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extends: existence
message: "Consider adding npm2yarn to ```bash"
link: https://docs.medusajs.com/contribution-guidelines#npm-and-yarn-code-blocks
level: warning
scope: code
scope: raw
ignorecase: true
raw:
- '```bash[\n]+npm'
7 changes: 7 additions & 0 deletions docs/styles/docs/TypeScript.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extends: existence
message: "Consider using typescript instead of tsx"
level: warning
scope: raw
ignorecase: true
raw:
- '```tsx'

0 comments on commit 6c6dfcd

Please sign in to comment.