Skip to content

Commit

Permalink
docs(core): Add more docs on ProductVariantPriceUpdateStrategy
Browse files Browse the repository at this point in the history
Relates to #2651
  • Loading branch information
michaelbromley committed Feb 9, 2024
1 parent 9099f35 commit 0ead892
Show file tree
Hide file tree
Showing 52 changed files with 248 additions and 219 deletions.
32 changes: 32 additions & 0 deletions docs/docs/guides/core-concepts/channels/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,38 @@ GBP and one for USD. This means that you are able to define multiple prices in d
**Note:** in the diagram above that the ProductVariant is **always assigned to the default Channel**, and thus will have a price in the default channel too. Likewise, the default Channel also has a defaultCurrencyCode. Depending on your requirements, you may or may not make use of the default Channel.
:::

### Keeping prices synchronized

When you have products assigned to multiple channels, updates to the price of a product in one channel will not automatically
be reflected in other channels. For instance, in the diagram above, both the Default channel and the UK channel have a price
in USD for the same product variant.

If an administrator of the UK channel changes the USD price to $20, the price in the Default channel will remain at $30. This
is the default behavior, and is controlled by the [ProductVariantPriceUpdateStrategy](/reference/typescript-api/configuration/product-variant-price-update-strategy).

If you want to keep prices synchronized across all channels, you can set the `syncPricesAcrossChannels` property of the
[DefaultProductVariantPriceUpdateStrategy](/reference/typescript-api/configuration/product-variant-price-update-strategy#defaultproductvariantpriceupdatestrategy)
to `true`. This will ensure that when the price of a product variant is updated in one channel, the price in all other channels
(of that particular currency) will be updated to match.

```ts
import { DefaultProductVariantPriceUpdateStrategy, VendureConfig } from '@vendure/core';

export const config: VendureConfig = {
// ...
// highlight-start
productVariantPriceUpdateStrategy: new DefaultProductVariantPriceUpdateStrategy({
syncPricesAcrossChannels: true,
}),
// highlight-end
// ...
};
```

You may however require even more sophisticated logic. For instance, you may want a one-way synchronization, where the price
in the Default channel is always the master price, and the prices in other channels are updated to match. In this case, you
can create a custom `ProductVariantPriceUpdateStrategy` which implements the desired logic.

## Use cases

### Single shop
Expand Down
13 changes: 13 additions & 0 deletions docs/docs/guides/how-to/multi-vendor-marketplaces/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ Executing the `registerNewSeller` mutation does the following:

Bob can now log in to the Admin UI using the provided credentials and begin creating products to sell!

### Keeping prices synchronized

In some marketplaces, the same product may be sold by multiple sellers. When this is the case, the product and its variants
will be assigned not only to the default channel, but to multiple other channels as well - see the
[Channels, Currencies & Prices section](/guides/core-concepts/channels/#channels-currencies--prices) for a visual explanation of how this works.

This means that there will be multiple ProductVariantPrice entities per variant, one for each channel.

In order
to keep prices synchronized across all channels, the example multi-vendor plugin sets the `syncPricesAcrossChannels` property
of the [DefaultProductVariantPriceUpdateStrategy](/reference/typescript-api/configuration/product-variant-price-update-strategy#defaultproductvariantpriceupdatestrategy)
to `true`. Your own multi-vendor implementation may require more sophisticated price synchronization logic, in which case
you can implement your own custom [ProductVariantPriceUpdateStrategy](/reference/typescript-api/configuration/product-variant-price-update-strategy).

## Assigning OrderLines to the correct Seller

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## ActionBarLocationId

<GenerationInfo sourceFile="packages/admin-ui/src/lib/core/src/common/component-registry-types.ts" sourceLine="104" packageName="@vendure/admin-ui" />
<GenerationInfo sourceFile="packages/admin-ui/src/lib/core/src/common/component-registry-types.ts" sourceLine="105" packageName="@vendure/admin-ui" />

The valid locationIds for registering action bar items.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type PageLocationId = | 'administrator-detail'
| 'job-list'
| 'order-detail'
| 'order-list'
| 'modify-order'
| 'payment-method-detail'
| 'payment-method-list'
| 'product-detail'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## CustomDetailComponentLocationId

<GenerationInfo sourceFile="packages/admin-ui/src/lib/core/src/common/component-registry-types.ts" sourceLine="112" packageName="@vendure/admin-ui" />
<GenerationInfo sourceFile="packages/admin-ui/src/lib/core/src/common/component-registry-types.ts" sourceLine="113" packageName="@vendure/admin-ui" />

The valid locations for embedding a <a href='/reference/admin-ui-api/custom-detail-components/custom-detail-component#customdetailcomponent'>CustomDetailComponent</a>.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TypedBaseListComponent<T extends TypedDocumentNode<any, Vars>, Field exten
createFilterCollection() => DataTableFilterCollection<NonNullable<NonNullable<Vars['options']>['filter']>>;
createSortCollection() => DataTableSortCollection<NonNullable<NonNullable<Vars['options']>['sort']>>;
setLanguage(code: LanguageCode) => ;
getCustomFieldConfig(key: Exclude<keyof CustomFields, '__typename'>) => CustomFieldConfig[];
getCustomFieldConfig(key: Exclude<keyof CustomFields, '__typename'> | string) => CustomFieldConfig[];
}
```
* Extends: <code><a href='/reference/admin-ui-api/list-detail-views/base-list-component#baselistcomponent'>BaseListComponent</a>&#60;ResultOf&#60;T&#62;, ItemOf&#60;ResultOf&#60;T&#62;, Field&#62;, VariablesOf&#60;T&#62;&#62;</code>
Expand Down Expand Up @@ -103,7 +103,7 @@ class TypedBaseListComponent<T extends TypedDocumentNode<any, Vars>, Field exten

### getCustomFieldConfig

<MemberInfo kind="method" type={`(key: Exclude&#60;keyof <a href='/reference/typescript-api/custom-fields/#customfields'>CustomFields</a>, '__typename'&#62;) => <a href='/reference/typescript-api/custom-fields/custom-field-config#customfieldconfig'>CustomFieldConfig</a>[]`} />
<MemberInfo kind="method" type={`(key: Exclude&#60;keyof <a href='/reference/typescript-api/custom-fields/#customfields'>CustomFields</a>, '__typename'&#62; | string) => <a href='/reference/typescript-api/custom-fields/custom-field-config#customfieldconfig'>CustomFieldConfig</a>[]`} />



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## ElasticsearchOptions

<GenerationInfo sourceFile="packages/elasticsearch-plugin/src/options.ts" sourceLine="31" packageName="@vendure/elasticsearch-plugin" />
<GenerationInfo sourceFile="packages/elasticsearch-plugin/src/options.ts" sourceLine="30" packageName="@vendure/elasticsearch-plugin" />

Configuration options for the <a href='/reference/core-plugins/elasticsearch-plugin/#elasticsearchplugin'>ElasticsearchPlugin</a>.

Expand All @@ -27,7 +27,8 @@ interface ElasticsearchOptions {
indexMappingProperties?: {
[indexName: string]: object;
};
batchSize?: number;
reindexProductsChunkSize?: number;
reindexBulkOperationSizeLimit?: number;
searchConfig?: SearchConfig;
customProductMappings?: {
[fieldName: string]: CustomMapping<[Product, ProductVariant[], LanguageCode, Injector, RequestContext]>;
Expand Down Expand Up @@ -157,11 +158,18 @@ indexMappingProperties: {
}
}
```
### batchSize
### reindexProductsChunkSize

<MemberInfo kind="property" type={`number`} default="2000" />
<MemberInfo kind="property" type={`number`} default="2500" since="2.1.7" />

Batch size for bulk operations (e.g. when rebuilding the indices).
Products limit chunk size for each loop iteration when indexing products.
### reindexBulkOperationSizeLimit

<MemberInfo kind="property" type={`number`} default="3000" since="2.1.7" />

Index operations are performed in bulk, with each bulk operation containing a number of individual
index operations. This option sets the maximum number of operations in the memory buffer before a
bulk operation is executed.
### searchConfig

<MemberInfo kind="property" type={`<a href='/reference/core-plugins/elasticsearch-plugin/elasticsearch-options#searchconfig'>SearchConfig</a>`} />
Expand Down Expand Up @@ -364,7 +372,7 @@ extend input SearchResultSortParameter {

## SearchConfig

<GenerationInfo sourceFile="packages/elasticsearch-plugin/src/options.ts" sourceLine="386" packageName="@vendure/elasticsearch-plugin" />
<GenerationInfo sourceFile="packages/elasticsearch-plugin/src/options.ts" sourceLine="395" packageName="@vendure/elasticsearch-plugin" />

Configuration options for the internal Elasticsearch query which is generated when performing a search.

Expand Down Expand Up @@ -645,7 +653,7 @@ searchConfig: {

## BoostFieldsConfig

<GenerationInfo sourceFile="packages/elasticsearch-plugin/src/options.ts" sourceLine="671" packageName="@vendure/elasticsearch-plugin" />
<GenerationInfo sourceFile="packages/elasticsearch-plugin/src/options.ts" sourceLine="680" packageName="@vendure/elasticsearch-plugin" />

Configuration for [boosting](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#field-boost)
the scores of given fields when performing a search against a term.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ Configuration for the EmailPlugin.
interface EmailPluginOptions {
templatePath?: string;
templateLoader?: TemplateLoader;
transport:
| EmailTransportOptions
| ((
injector?: Injector,
ctx?: RequestContext,
transport:
| EmailTransportOptions
| ((
injector?: Injector,
ctx?: RequestContext,
) => EmailTransportOptions | Promise<EmailTransportOptions>);
handlers: Array<EmailEventHandler<string, any>>;
globalTemplateVars?: { [key: string]: any };
Expand All @@ -38,43 +38,43 @@ interface EmailPluginOptions {

<MemberInfo kind="property" type={`string`} />

The path to the location of the email templates. In a default Vendure installation,
The path to the location of the email templates. In a default Vendure installation,
the templates are installed to `<project root>/vendure/email/templates`.
### templateLoader

<MemberInfo kind="property" type={`<a href='/reference/core-plugins/email-plugin/template-loader#templateloader'>TemplateLoader</a>`} since="2.0.0" />

An optional TemplateLoader which can be used to load templates from a custom location or async service.
An optional TemplateLoader which can be used to load templates from a custom location or async service.
The default uses the FileBasedTemplateLoader which loads templates from `<project root>/vendure/email/templates`
### transport

<MemberInfo kind="property" type={`| <a href='/reference/core-plugins/email-plugin/transport-options#emailtransportoptions'>EmailTransportOptions</a> | (( injector?: <a href='/reference/typescript-api/common/injector#injector'>Injector</a>, ctx?: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, ) =&#62; <a href='/reference/core-plugins/email-plugin/transport-options#emailtransportoptions'>EmailTransportOptions</a> | Promise&#60;<a href='/reference/core-plugins/email-plugin/transport-options#emailtransportoptions'>EmailTransportOptions</a>&#62;)`} />
<MemberInfo kind="property" type={`| <a href='/reference/core-plugins/email-plugin/transport-options#emailtransportoptions'>EmailTransportOptions</a> | (( injector?: <a href='/reference/typescript-api/common/injector#injector'>Injector</a>, ctx?: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, ) =&#62; <a href='/reference/core-plugins/email-plugin/transport-options#emailtransportoptions'>EmailTransportOptions</a> | Promise&#60;<a href='/reference/core-plugins/email-plugin/transport-options#emailtransportoptions'>EmailTransportOptions</a>&#62;)`} />

Configures how the emails are sent.
### handlers

<MemberInfo kind="property" type={`Array&#60;<a href='/reference/core-plugins/email-plugin/email-event-handler#emaileventhandler'>EmailEventHandler</a>&#60;string, any&#62;&#62;`} />

An array of <a href='/reference/core-plugins/email-plugin/email-event-handler#emaileventhandler'>EmailEventHandler</a>s which define which Vendure events will trigger
An array of <a href='/reference/core-plugins/email-plugin/email-event-handler#emaileventhandler'>EmailEventHandler</a>s which define which Vendure events will trigger
emails, and how those emails are generated.
### globalTemplateVars

<MemberInfo kind="property" type={`{ [key: string]: any }`} />

An object containing variables which are made available to all templates. For example,
the storefront URL could be defined here and then used in the "email address verification"
An object containing variables which are made available to all templates. For example,
the storefront URL could be defined here and then used in the "email address verification"
email.
### emailSender

<MemberInfo kind="property" type={`<a href='/reference/core-plugins/email-plugin/email-sender#emailsender'>EmailSender</a>`} default="<a href='/reference/core-plugins/email-plugin/email-sender#nodemaileremailsender'>NodemailerEmailSender</a>" />

An optional allowed EmailSender, used to allow custom implementations of the send functionality
An optional allowed EmailSender, used to allow custom implementations of the send functionality
while still utilizing the existing emailPlugin functionality.
### emailGenerator

<MemberInfo kind="property" type={`<a href='/reference/core-plugins/email-plugin/email-generator#emailgenerator'>EmailGenerator</a>`} default="<a href='/reference/core-plugins/email-plugin/email-generator#handlebarsmjmlgenerator'>HandlebarsMjmlGenerator</a>" />

An optional allowed EmailGenerator, used to allow custom email generation functionality to
An optional allowed EmailGenerator, used to allow custom email generation functionality to
better match with custom email sending functionality.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## BullMQJobQueueStrategy

<GenerationInfo sourceFile="packages/job-queue-plugin/src/bullmq/bullmq-job-queue-strategy.ts" sourceLine="40" packageName="@vendure/job-queue-plugin" />
<GenerationInfo sourceFile="packages/job-queue-plugin/src/bullmq/bullmq-job-queue-strategy.ts" sourceLine="42" packageName="@vendure/job-queue-plugin" />

This JobQueueStrategy uses [BullMQ](https://docs.bullmq.io/) to implement a push-based job queue
on top of Redis. It should not be used alone, but as part of the <a href='/reference/core-plugins/job-queue-plugin/bull-mqjob-queue-plugin#bullmqjobqueueplugin'>BullMQJobQueuePlugin</a>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Configuration options for the <a href='/reference/core-plugins/job-queue-plugin/
```ts title="Signature"
interface BullMQPluginOptions {
connection?: ConnectionOptions;
queueOptions?: Exclude<QueueOptions, 'connection'>;
workerOptions?: Exclude<WorkerOptions, 'connection'>;
queueOptions?: Omit<QueueOptions, 'connection'>;
workerOptions?: Omit<WorkerOptions, 'connection'>;
setRetries?: (queueName: string, job: Job) => number;
setBackoff?: (queueName: string, job: Job) => BackoffOptions | undefined;
}
Expand All @@ -37,14 +37,14 @@ creating a new Queue, Worker and Scheduler instance.
If omitted, it will attempt to connect to Redis at `127.0.0.1:6379`.
### queueOptions

<MemberInfo kind="property" type={`Exclude&#60;QueueOptions, 'connection'&#62;`} />
<MemberInfo kind="property" type={`Omit&#60;QueueOptions, 'connection'&#62;`} />

Additional options used when instantiating the BullMQ
Queue instance.
See the [BullMQ QueueOptions docs](https://github.com/taskforcesh/bullmq/blob/master/docs/gitbook/api/bullmq.queueoptions.md)
### workerOptions

<MemberInfo kind="property" type={`Exclude&#60;WorkerOptions, 'connection'&#62;`} />
<MemberInfo kind="property" type={`Omit&#60;WorkerOptions, 'connection'&#62;`} />

Additional options used when instantiating the BullMQ
Worker instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ export const config: VendureConfig = {
}),
],
};
```

Note: If the `paymentIntentCreateParams` is also used and returns a `metadata` key, then the values
returned by both functions will be merged.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/reference/core-plugins/sentry-plugin/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## SentryPlugin

<GenerationInfo sourceFile="packages/sentry-plugin/src/sentry-plugin.ts" sourceLine="109" packageName="@vendure/sentry-plugin" />
<GenerationInfo sourceFile="packages/sentry-plugin/src/sentry-plugin.ts" sourceLine="108" packageName="@vendure/sentry-plugin" />

This plugin integrates the [Sentry](https://sentry.io) error tracking & performance monitoring
service with your Vendure server. In addition to capturing errors, it also provides built-in
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/reference/typescript-api/assets/asset-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## AssetOptions

<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="624" packageName="@vendure/core" />
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="626" packageName="@vendure/core" />

The AssetOptions define how assets (images and other files) are named and stored, and how preview images are generated.

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/reference/typescript-api/auth/auth-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## AuthOptions

<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="326" packageName="@vendure/core" />
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="328" packageName="@vendure/core" />

The AuthOptions define how authentication and authorization is managed.

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/reference/typescript-api/auth/cookie-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## CookieOptions

<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="221" packageName="@vendure/core" />
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="223" packageName="@vendure/core" />

Options for the handling of the cookies used to track sessions (only applicable if
`authOptions.tokenMethod` is set to `'cookie'`). These options are passed directly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## SuperadminCredentials

<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="790" packageName="@vendure/core" />
<GenerationInfo sourceFile="packages/core/src/config/vendure-config.ts" sourceLine="802" packageName="@vendure/core" />

These credentials will be used to create the Superadmin user & administrator
when Vendure first bootstraps.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/reference/typescript-api/common/currency-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## CurrencyCode

<GenerationInfo sourceFile="packages/common/src/generated-types.ts" sourceLine="962" packageName="@vendure/common" />
<GenerationInfo sourceFile="packages/common/src/generated-types.ts" sourceLine="968" packageName="@vendure/common" />

ISO 4217 currency code

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/reference/typescript-api/common/job-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## JobState

<GenerationInfo sourceFile="packages/common/src/generated-types.ts" sourceLine="2107" packageName="@vendure/common" />
<GenerationInfo sourceFile="packages/common/src/generated-types.ts" sourceLine="2125" packageName="@vendure/common" />

The state of a Job in the JobQueue

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/reference/typescript-api/common/language-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## LanguageCode

<GenerationInfo sourceFile="packages/common/src/generated-types.ts" sourceLine="2125" packageName="@vendure/common" />
<GenerationInfo sourceFile="packages/common/src/generated-types.ts" sourceLine="2143" packageName="@vendure/common" />

Languages in the form of a ISO 639-1 language code with optional
region or script modifier (e.g. de_AT). The selection available is based
Expand Down
Loading

0 comments on commit 0ead892

Please sign in to comment.