Skip to content

Allow for the primary media for a sku to be removed#1410

Merged
jefffischer merged 4 commits intoBroadleafCommerce-4.0.xfrom
qa-256-remove-primary-media
Jul 24, 2015
Merged

Allow for the primary media for a sku to be removed#1410
jefffischer merged 4 commits intoBroadleafCommerce-4.0.xfrom
qa-256-remove-primary-media

Conversation

@cja769
Copy link

@cja769 cja769 commented Jun 11, 2015

This fixes #1228 by adding a GUI button that clears the image and value so that "null" is sent to the server. Next the old media object is removed from the database since the newMedia object is null. Lastly the sku-media map entry for its primary image is removed.

@bpolster
Copy link
Member

This looks like something that should be tested in community

@bpolster
Copy link
Member

bpolster commented Jul 6, 2015

BroadleafCommerce/QA#256

@jefffischer
Copy link
Member

This is close, but unfortunately it breaks down under the following scenario:

  1. Go into the "test" site in demo private
  2. Go to Green Ghost and clear the primary image and save
  3. Select a new image and save
  4. Go to My Changes and revert
  5. Go back to the Green Ghost product details screen and you will see the primary image is missing (incorrect)

The problem is that the original clear creates a delete record in BLC_SKU_MEDIA_MAP, and then the subsequent setting of a different image creates an add record in BLC_SKU_MEDIA_MAP. The revert only ends up archiving the add record and the delete record is essentially orphaned.

This enhancement needs to, upon every save, revert any existing changes to primary media before applying a different change to primary media. This guarantees there is only ever one active change for this property in the user sandbox. We do something similar to this for defaultCategory on product. In EnterpriseProductCustomPersistenceHandlerExtensionHandler.manageParentCategoryForUpdate(..), the revertExistingUserEdits(..) call performs a similar function for defaultCategory property. In MediaFieldPersistenceProvider, you need to add an extension point to the MediaFieldPersistenceProviderExtensionHandler interface and implement your similar "revertExistingUserEdits" code in the extension point in WorkflowMediaFieldPersistenceProviderExtensionHandler.

jefffischer pushed a commit that referenced this pull request Jul 24, 2015
…-media

Allow for the primary media for a sku to be removed
@jefffischer jefffischer merged commit c67a68a into BroadleafCommerce-4.0.x Jul 24, 2015
@jefffischer jefffischer deleted the qa-256-remove-primary-media branch July 24, 2015 14:56
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 this pull request may close these issues.

4 participants