Sylius: Product variant Images

Created on 26 Apr 2017  ·  4Comments  ·  Source: Sylius/Sylius

There is no way to get images of a product variant without loading all the images of the parent product.

An association should be added between productVariant and productImage, so I can fetch images from product variant entity.

Also, productVariant API should be able to return productVariant's images.

Most helpful comment

@pjedrzejewski , I already implemented this issue for a private project.
I will create a pull request for this.

All 4 comments

It will introduce a BC break, but I would rather consider this as a bug fix than have it not fixed. @lchrusciel came into the same issue this week. @Sylius/core-team any thoughts on this one?

I think it is not a huge bc break, but valid and common use case, so I am 👍 to do it.

@pjedrzejewski , I already implemented this issue for a private project.
I will create a pull request for this.

@pamil @pjedrzejewski
After analyzing the current design of images, I found that we are not good.

Product and Taxon model both have a one-to-many uni-direction link to image.
Product variant don't share the same mapping, it have many-to-many multi-direction link to image.

Therefor, Product variant can not implement the interface ImageAwareInterface, which make development heavy (Found my self obliged to create new interface ProductImageAwareInterface and to change ImagesUploaderListner )

I think the best solution, Is to keep it simple, and to delete the link from image to product variant (ProductImage model), so we end up with a coherent design. Only subject can get it's images. Images doesn't know about products..

Was this page helpful?
0 / 5 - 0 ratings