***

title: "StockLocationService"
generated: true
---------------

<GenerationInfo sourceFile="packages/core/src/service/services/stock-location.service.ts" sourceLine="41" packageName="@vendure/core" />

Contains methods relating to [StockLocation](/current/core/reference/typescript-api/entities/stock-location#stocklocation) entities.

```ts title="Signature"
class StockLocationService {
    constructor(requestContextService: RequestContextService, connection: TransactionalConnection, channelService: ChannelService, roleService: RoleService, listQueryBuilder: ListQueryBuilder, configService: ConfigService, requestContextCache: RequestContextCacheService, customFieldRelationService: CustomFieldRelationService, eventBus: EventBus)
    initStockLocations() => ;
    findOne(ctx: RequestContext, stockLocationId: ID) => Promise<StockLocation | undefined>;
    findAll(ctx: RequestContext, options?: ListQueryOptions<StockLocation>, relations?: RelationPaths<StockLocation>) => Promise<PaginatedList<StockLocation>>;
    create(ctx: RequestContext, input: CreateStockLocationInput) => Promise<StockLocation>;
    update(ctx: RequestContext, input: UpdateStockLocationInput) => Promise<StockLocation>;
    delete(ctx: RequestContext, input: DeleteStockLocationInput) => Promise<DeletionResponse>;
    assignStockLocationsToChannel(ctx: RequestContext, input: AssignStockLocationsToChannelInput) => Promise<StockLocation[]>;
    removeStockLocationsFromChannel(ctx: RequestContext, input: RemoveStockLocationsFromChannelInput) => Promise<StockLocation[]>;
    defaultStockLocation(ctx: RequestContext) => ;
    getAllocationLocations(ctx: RequestContext, orderLine: OrderLine, quantity: number) => ;
    getReleaseLocations(ctx: RequestContext, orderLine: OrderLine, quantity: number) => ;
    getSaleLocations(ctx: RequestContext, orderLine: OrderLine, quantity: number) => ;
    getCancellationLocations(ctx: RequestContext, orderLine: OrderLine, quantity: number) => ;
}
```

<div className="members-wrapper">

### initStockLocations

\<MemberInfo kind="method" type={`() => `}   />

### findOne

\<MemberInfo kind="method" type={`(ctx: <a href='/current/core/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, stockLocationId: <a href='/current/core/reference/typescript-api/common/id#id'>ID</a>) => Promise<<a href='/current/core/reference/typescript-api/entities/stock-location#stocklocation'>StockLocation</a> | undefined>`}   />

### findAll

\<MemberInfo kind="method" type={`(ctx: <a href='/current/core/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, options?: ListQueryOptions<<a href='/current/core/reference/typescript-api/entities/stock-location#stocklocation'>StockLocation</a>>, relations?: RelationPaths<<a href='/current/core/reference/typescript-api/entities/stock-location#stocklocation'>StockLocation</a>>) => Promise<<a href='/current/core/reference/typescript-api/common/paginated-list#paginatedlist'>PaginatedList</a><<a href='/current/core/reference/typescript-api/entities/stock-location#stocklocation'>StockLocation</a>>>`}   />

### create

\<MemberInfo kind="method" type={`(ctx: <a href='/current/core/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, input: CreateStockLocationInput) => Promise<<a href='/current/core/reference/typescript-api/entities/stock-location#stocklocation'>StockLocation</a>>`}   />

### update

\<MemberInfo kind="method" type={`(ctx: <a href='/current/core/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, input: UpdateStockLocationInput) => Promise<<a href='/current/core/reference/typescript-api/entities/stock-location#stocklocation'>StockLocation</a>>`}   />

### delete

\<MemberInfo kind="method" type={`(ctx: <a href='/current/core/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, input: DeleteStockLocationInput) => Promise<DeletionResponse>`}   />

Deletes a StockLocation. If `transferToLocationId` is specified in the input, all stock levels
from the deleted location will be transferred to the target location. The last StockLocation
cannot be deleted.

### assignStockLocationsToChannel

\<MemberInfo kind="method" type={`(ctx: <a href='/current/core/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, input: AssignStockLocationsToChannelInput) => Promise<<a href='/current/core/reference/typescript-api/entities/stock-location#stocklocation'>StockLocation</a>[]>`}   />

Assigns multiple StockLocations to the specified Channel. Requires the `UpdateStockLocation`
permission on the target channel.

### removeStockLocationsFromChannel

\<MemberInfo kind="method" type={`(ctx: <a href='/current/core/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, input: RemoveStockLocationsFromChannelInput) => Promise<<a href='/current/core/reference/typescript-api/entities/stock-location#stocklocation'>StockLocation</a>[]>`}   />

Removes multiple StockLocations from the specified Channel. Requires the `DeleteStockLocation`
permission on the target channel. StockLocations cannot be removed from the default channel.

### defaultStockLocation

\<MemberInfo kind="method" type={`(ctx: <a href='/current/core/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>) => `}   />

### getAllocationLocations

\<MemberInfo kind="method" type={`(ctx: <a href='/current/core/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, orderLine: <a href='/current/core/reference/typescript-api/entities/order-line#orderline'>OrderLine</a>, quantity: number) => `}   />

Returns the locations and quantities to use for allocating stock when an OrderLine is created.
This uses the configured [StockLocationStrategy](/current/core/reference/typescript-api/products-stock/stock-location-strategy#stocklocationstrategy).

### getReleaseLocations

\<MemberInfo kind="method" type={`(ctx: <a href='/current/core/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, orderLine: <a href='/current/core/reference/typescript-api/entities/order-line#orderline'>OrderLine</a>, quantity: number) => `}   />

Returns the locations and quantities to use for releasing allocated stock when an OrderLine is cancelled
or modified. This uses the configured [StockLocationStrategy](/current/core/reference/typescript-api/products-stock/stock-location-strategy#stocklocationstrategy).

### getSaleLocations

\<MemberInfo kind="method" type={`(ctx: <a href='/current/core/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, orderLine: <a href='/current/core/reference/typescript-api/entities/order-line#orderline'>OrderLine</a>, quantity: number) => `}   />

Returns the locations and quantities to use for creating sales when an Order is fulfilled.
This uses the configured [StockLocationStrategy](/current/core/reference/typescript-api/products-stock/stock-location-strategy#stocklocationstrategy).

### getCancellationLocations

\<MemberInfo kind="method" type={`(ctx: <a href='/current/core/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, orderLine: <a href='/current/core/reference/typescript-api/entities/order-line#orderline'>OrderLine</a>, quantity: number) => `}   />

Returns the locations and quantities to use for cancelling sales when an OrderLine is cancelled
after fulfillment. This uses the configured [StockLocationStrategy](/current/core/reference/typescript-api/products-stock/stock-location-strategy#stocklocationstrategy).

</div>
