Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot re-assign images to another variant of the same product #3804

Closed
felixyz opened this issue Oct 22, 2020 · 0 comments · Fixed by #3810
Closed

Cannot re-assign images to another variant of the same product #3804

felixyz opened this issue Oct 22, 2020 · 0 comments · Fixed by #3810

Comments

@felixyz
Copy link
Contributor

felixyz commented Oct 22, 2020

I have a problem concerning re-assigning images to another variant of the same product. Didn't have this problem in older versions of Solidus (but don't know when it came about).

Solidus Version:

2.11.0.alpha

To Reproduce

  1. Go to /admin/products/my-product/images for a product with multiple variants and multiple images,
  2. Re-assign an image from one variant to another
  3. Press the "Save" icon

Current behavior

The update fails and the "The resource you were looking for could not be found" flash message is displayed. The image is not re-assigned.

Expected behavior

The update succeeds, the success flash message is displayed, and the image is re-assigned to the selected variant.

Desktop:

  • OS: Ubuntu 20.04
  • Browser: Firefox - Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser: Firefox 81.0

Additional context

The view for the images tab loads images using @product.gallery.images which will get all images from all of the product's variants (has_many :variant_images, -> { order(:position) }, source: :images, through: :variants_including_master).

But Spree::Api::ImagesController#update only tries to select the image for update with

@image = scope.images.accessible_by(current_ability, :update).find(params[:id])

where scope is a Spree::Product - in other words, images assigned to variants will not be found.

felixyz added a commit to felixyz/solidus that referenced this issue Oct 26, 2020
felixyz added a commit to felixyz/solidus that referenced this issue Oct 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant