fix: export ProductImage to allow for custom links to add alt text (#12357)

This commit is contained in:
Harminder Virk
2025-05-05 14:24:25 +05:30
committed by GitHub
parent c35e9e5104
commit e4d853185f
6 changed files with 33 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
"@medusajs/product": patch
---
fix: export ProductImage to allow for custom links to add alt text

View File

@@ -9,7 +9,8 @@ const eventBaseNames: [
"productType",
"productTag",
"productCategory",
"productCollection"
"productCollection",
"productImage"
] = [
"product",
"productVariant",
@@ -19,6 +20,7 @@ const eventBaseNames: [
"productTag",
"productCategory",
"productCollection",
"productImage",
]
export const ProductEvents = buildEventNamesFromEntityName(

View File

@@ -1161,6 +1161,14 @@ moduleIntegrationTestRunner<IProductModuleService>({
source: Modules.PRODUCT,
action: CommonEvents.DELETED,
}),
composeMessage(ProductEvents.PRODUCT_IMAGE_DELETED, {
data: {
id: [products[0].images[0].id],
},
object: "product_image",
source: Modules.PRODUCT,
action: CommonEvents.DELETED,
}),
composeMessage(ProductEvents.PRODUCT_OPTION_VALUE_DELETED, {
data: {
id: [products[0].options[0].values[0].id],

View File

@@ -55,7 +55,7 @@ moduleIntegrationTestRunner<Service>({
service: ProductModuleService,
}).linkable
expect(Object.keys(linkable)).toHaveLength(8)
expect(Object.keys(linkable)).toHaveLength(9)
expect(Object.keys(linkable)).toEqual(
expect.arrayContaining([
"product",
@@ -66,6 +66,7 @@ moduleIntegrationTestRunner<Service>({
"productTag",
"productCollection",
"productCategory",
"productImage",
])
)
@@ -153,6 +154,15 @@ moduleIntegrationTestRunner<Service>({
field: "productCategory",
},
},
productImage: {
id: {
entity: "ProductImage",
field: "productImage",
linkable: "product_image_id",
primaryKey: "id",
serviceName: "product",
},
},
})
})

View File

@@ -3,6 +3,7 @@ import {
Product,
ProductCategory,
ProductCollection,
ProductImage,
ProductOption,
ProductOptionValue,
ProductTag,
@@ -22,6 +23,7 @@ export const joinerConfig = defineJoinerConfig(Modules.PRODUCT, {
ProductTag,
ProductCollection,
ProductCategory,
ProductImage,
],
linkableKeys: {
// Merged with the autogenerated ones to maintain backward compatibility

View File

@@ -96,6 +96,9 @@ export default class ProductModuleService
ProductVariant: {
dto: ProductTypes.ProductVariantDTO
}
ProductImage: {
dto: ProductTypes.ProductImageDTO
}
}>({
Product,
ProductCategory,
@@ -105,6 +108,7 @@ export default class ProductModuleService
ProductTag,
ProductType,
ProductVariant,
ProductImage,
})
implements ProductTypes.IProductModuleService
{