#To extend an inventory service I have to create a custom inventory module?
12 messages · Page 1 of 1 (latest)
seems like the service is not exported
in inventory/index.ts
nope, this gives container errors
- Initializing subscribers
error: Error starting server
AwilixResolutionError: Could not resolve 'inventoryItemService'.
Resolution path: productVariantInventoryService -> salesChannelInventoryService -> inventoryService -> inventoryItemService
up
@faint palm you have to extend all of them, even if. you don't add or override any logic, the core app needs to have all the services above
@trail finch ah, so I have to extend all services that are in inventory/dist?
correct
thx!
can you share your example? because I'm trying and it's not overriding anything
I added file services/inventory/index.ts
and inside I'm overriding functionality like:
InventoryService as MedusaInventoryService,
InventoryItemService,
InventoryLevelService,
ReservationItemService,
} from '@medusajs/inventory/dist/services';
import { InternalModuleDeclaration } from '@medusajs/modules-sdk';
class InventoryService extends MedusaInventoryService {
constructor(
dependencies: any,
options?: unknown,
moduleDeclaration?: InternalModuleDeclaration | undefined
) {
super(dependencies, options, moduleDeclaration);
console.log('OVERRIDING CORRECTLY');
}
}
export {
InventoryItemService,
InventoryLevelService,
ReservationItemService,
InventoryService,
};
you need to create a new module where you re export everything that is exported except your service which will replace the existing one. You might also need to update the loader container from your modukle