diff --git a/vendor/magento/module-catalog/Model/ProductMutex.php b/vendor/magento/module-catalog/Model/ProductMutex.php new file mode 100644 index 0000000000000..5cbe10ce484e3 --- /dev/null +++ b/vendor/magento/module-catalog/Model/ProductMutex.php @@ -0,0 +1,46 @@ +lockManager->lock(self::LOCK_PREFIX . $sku, $this->lockWaitTimeout)) { + try { + $result = $callable(...$args); + } finally { + $this->lockManager->unlock(self::LOCK_PREFIX . $sku); + } + } else { + throw new ProductMutexException( + __('Could not acquire lock for SKU %1', $sku) + ); + } + return $result; + } +} diff --git a/vendor/magento/module-catalog/Model/ProductMutexException.php b/vendor/magento/module-catalog/Model/ProductMutexException.php new file mode 100644 index 0000000000000..49a4f01d923d5 --- /dev/null +++ b/vendor/magento/module-catalog/Model/ProductMutexException.php @@ -0,0 +1,15 @@ +productMutex->execute((string) $product->getSku(), $proceed, $product, $saveOptions); + } catch (ProductMutexException $e) { + throw new CouldNotSaveException( + __('The product was unable to be saved. Please try again.'), + $e + ); + } + } +} diff --git a/vendor/magento/module-catalog/etc/di.xml b/vendor/magento/module-catalog/etc/di.xml index e817bcbb42d25..760d8d3428029 100644 --- a/vendor/magento/module-catalog/etc/di.xml +++ b/vendor/magento/module-catalog/etc/di.xml @@ -77,6 +77,7 @@ + @@ -1328,6 +1329,7 @@ + diff --git a/vendor/magento/module-catalog/i18n/en_US.csv b/vendor/magento/module-catalog/i18n/en_US.csv index d09e8a4aa62a3..573f5c5fd0af4 100644 --- a/vendor/magento/module-catalog/i18n/en_US.csv +++ b/vendor/magento/module-catalog/i18n/en_US.csv @@ -803,6 +803,7 @@ Details,Details "Add To Compare","Add To Compare" "Learn more","Learn more" "Recently Viewed","Recently Viewed" +"Could not acquire lock for SKU %1","Could not acquire lock for SKU %1" "The value of Admin must be unique.", "The value of Admin must be unique." "The value of Admin must be unique. (%1)", "The value of Admin must be unique. (%1)" "Product Name or SKU", "Product Name or SKU"