Skip to content

Commit b14c1c7

Browse files
authored
Merge pull request #8612 from woocommerce/issue/8551-update-product
Variations: Update product variation count after generating variations
2 parents dd2f224 + f0bfd44 commit b14c1c7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

WooCommerce/Classes/ViewRelated/Products/Variations/ProductVariationsViewController.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,13 @@ private extension ProductVariationsViewController {
697697
let notice = Notice(title: Localization.variationsCreatedTitle)
698698
noticePresenter.enqueue(notice: notice)
699699
}
700+
701+
/// Updates the current product with the up-to-date list of variations IDs.
702+
/// This is needed in order to reflect variations count changes back to this and to other screens.
703+
///
704+
private func updateProductVariationCount() {
705+
self.product = product.copy(variations: resultsController.fetchedObjects.map { $0.productVariationID })
706+
}
700707
}
701708

702709
// MARK: - Placeholders
@@ -786,6 +793,7 @@ extension ProductVariationsViewController: SyncingCoordinatorDelegate {
786793
case .finished(let variationsCreated):
787794
self?.dismissBlockingIndicator()
788795
if variationsCreated {
796+
self?.updateProductVariationCount()
789797
self?.presentVariationsCreatedNotice()
790798
} else {
791799
self?.presentNoGenerationNotice()

0 commit comments

Comments
 (0)