1

I am building a custom e-commmerce website in Rails.

In my data model products have many SKUs, and SKUs have two properties: size and color.

I am wondering how I should add product images to this scheme.

One natural thing would be to put them on the product via a has_many relationship. But if I do this it might be difficult to account for the fact that SKUs with different colors on the same product have different images.

If, on the other hand, I add product images to SKUs in a has_many fashion then that will solve the color issue but raise a new one: within a color all SKUs have the same product images, regardless of their size.

I.e., product size doesn't affect a product's images but product color does.

Given that adding images to both products and SKUs has problems, perhaps I need to create a new model that captures the idea of UserFacingProductEntity.

However this problem must have been solved before.

Tom Lehman
  • 85,973
  • 71
  • 200
  • 272

1 Answers1

0

I was going to do this in a comment but it's not going to fit.

IMHO, it's how sku is defined. It's a common "issue", particularly if you're working to support an existing dataset (often years in the making, which means, can't change).

TLDR; each variation of a Product is a sku, it will be fulfilled/manufactured/distributed/tracked/reported on, that way anyway.


How "deep" variations go, color and size skus each? vs sizes are just "facets" of Color variation skus, will likely be dictated by business' product line.

Practical example: If I ordered ITEM A in RED, size L:

  • how would I communicate that to both end user (display) and fulfillment operations (back office)?
    • pick/pack SKU 123 (red), and then find the "bin" with size L?
    • Is there even inventory? for 123L?
    • How do I manage ITEM A, RED, size L inventory, pricing, etc. (vs sizes XL, M, S, etc)?

Or:

  • is it "better" if sku 123 refers specifically to ITEM A, RED, Large? managed as it's own (mfg, inventory, pricing, etc)

At this point, the image (as above, only one aspect to consider) lives at the color variation sku level and/or size if it's is enough of a product type factor.

Hth...

EdSF
  • 11,753
  • 6
  • 42
  • 83