diff --git a/vendor/magento/module-catalog/Model/ProductMutex.php b/vendor/magento/module-catalog/Model/ProductMutex.php new file mode 100644 index 00000000000..5cbe10ce484 --- /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 00000000000..49a4f01d923 --- /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 df36733051c..4d19e858a78 100644 --- a/vendor/magento/module-catalog/etc/di.xml +++ b/vendor/magento/module-catalog/etc/di.xml @@ -79,6 +79,7 @@ + @@ -1330,6 +1331,7 @@ + diff --git a/vendor/magento/module-catalog/i18n/en_US.csv b/vendor/magento/module-catalog/i18n/en_US.csv index b9fdf6b4324..eedc11dfb4f 100644 --- a/vendor/magento/module-catalog/i18n/en_US.csv +++ b/vendor/magento/module-catalog/i18n/en_US.csv @@ -804,6 +804,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"