I cannot see any event for price_list.created!! I wanted this because when I subscribe to this event then the sale price must get associate with a particular product and in meilisearch I need this sale price info to be displayed along with other attributes like product title,category,price,origin_country. But since price_list are not directly related to product so how do I relate the price_list to product...Because I want the sale price to be displayed also....please please help!!
#No event is registered when a new price-list is created
6 messages · Page 1 of 1 (latest)
You're right there is no event when a price list is created, however you can create your own
What about extending the PriceListService and overriding the create fn like this :
import {
EventBusService,
PriceListService as MedusaPriceListService,
Selector,
} from '@medusajs/medusa'
type InjectedDependencies = {
eventBusService : EventBusService
}
class PriceListService extends MedusaPriceListService{
static LIFE_TIME = Lifetime.SCOPED
private readonly eventBus_: EventBusService
static readonly Events = {
CREATED: "price-list.created",
// Other events...
}
constructor(container){
super(...arguments)
this.eventBus_ = container.eventBusService
}
async create(
priceListObject: CreatePriceListInput
): Promise<PriceList | never> {
const priceList = await super.create(priceListObject)
await this.eventBus_.emit(PriceListService.Events.CREATED, priceList)
return priceList
}
}
It will work but I don't know if it's the right thing to do though, since in the core services they uses transactions, I'm wondering if you lose the benefits of it by doing this 🤔
If it solves your issue make sure to mark as solved 👍
okay
@humble pollen Can you please tell me is there a way to refresh access tokens which are created when user logins with JWT?