Add image upload support for product variants#14511
Draft
chahmedejaz wants to merge 7 commits into
Draft
Conversation
- Implemented image upload functionality for variants in the images controller. - Updated helper methods to handle image paths for both products and variants. - Created new view partials for rendering images and updated existing ones. - Enhanced tests to cover image upload and update scenarios for variants. - Modified localization for image edit modal to reflect resource type.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What? Why?
Enterprise users can now upload images for individual product variants from the admin products page. Previously, only product-level images were supported — variant rows showed an empty column with no placeholder, and the image upload overlay only handled products.
This change:
has_one :imageassociation toSpree::Variant, reusing the existingSpree::Imagemodel (which was already polymorphic viaviewable_type/viewable_id).variant_idparam, setting the correctviewable_type(Spree::VariantvsSpree::Product) and redirecting back to the admin products list after save._product_imagepartial with a generic_imagepartial that works for both products and variants.What should we test?
Placeholder image for variants without an image
Upload an image for a variant
Upload an invalid file type
Update an existing variant image
Product image upload still works
Readonly product/variant image displays without edit button
create_linked_variantspermission (notmanage_products) on another producer's variant.Variant image redirects to product list
Migration — existing variant images are removed
Spree::Imagerecords withviewable_type = 'Spree::Variant', verify they are cleaned up after runningdb:migrate. Product images are unaffected.Any other scenario mentioned in the issue and regression testing of the product page.
Release notes
Changelog Category (reviewers may add a label for the release notes):