avoid 'Copy of Copy of Copy of ...' infinite prefixing of copies
This commit is contained in:
parent
43f158d4c1
commit
ca79b8b329
|
|
@ -5,8 +5,8 @@ return [
|
|||
'create' => 'خلق',
|
||||
'update' => 'تحديث',
|
||||
'delete' => 'حذف',
|
||||
'copy-of' => 'نسخة من',
|
||||
'copy-of-slug' => 'نسخة-من',
|
||||
'copy-of' => 'نسخة من ',
|
||||
'copy-of-slug' => 'نسخة-من-',
|
||||
'failed' => 'فشل',
|
||||
'store' => 'متجر',
|
||||
'image' => 'صورة',
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
return [
|
||||
'save' => 'Speichern',
|
||||
'copy-of' => 'Kopie von',
|
||||
'copy-of-slug' => 'kopie-von',
|
||||
'copy-of' => 'Kopie von ',
|
||||
'copy-of-slug' => 'kopie-von-',
|
||||
'create' => 'Erstellen',
|
||||
'update' => 'Update',
|
||||
'delete' => 'Löschen',
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
return [
|
||||
'save' => 'Save',
|
||||
'copy-of' => 'Copy of',
|
||||
'copy-of-slug' => 'copy-of',
|
||||
'copy-of' => 'Copy of ',
|
||||
'copy-of-slug' => 'copy-of-',
|
||||
'create' => 'Create',
|
||||
'update' => 'Update',
|
||||
'delete' => 'Delete',
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Webkul\CartRule\Http\Controllers;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
|
@ -87,7 +88,7 @@ class CartRuleController extends Controller
|
|||
->replicate()
|
||||
->fill([
|
||||
'status' => 0,
|
||||
'name' => __('admin::app.copy-of') . ' ' . $originalCartRule->name,
|
||||
'name' => __('admin::app.copy-of') . $originalCartRule->name,
|
||||
]);
|
||||
|
||||
$copiedCartRule->save();
|
||||
|
|
@ -209,7 +210,7 @@ class CartRuleController extends Controller
|
|||
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Cart Rule']));
|
||||
|
||||
return response()->json(['message' => true], 200);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Cart Rule']));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace Webkul\Product\Repositories;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Webkul\Product\Models\Product;
|
||||
use Illuminate\Pagination\Paginator;
|
||||
|
|
@ -613,8 +614,9 @@ class ProductRepository extends Repository
|
|||
$newValue = $oldValue->replicate();
|
||||
|
||||
if ($oldValue->attribute_id === $attributeIds['name']) {
|
||||
$copiedName = sprintf('%s %s (%s)',
|
||||
trans('admin::app.copy-of'),
|
||||
$copyOf = trans('admin::app.copy-of');
|
||||
$copiedName = sprintf('%s%s (%s)',
|
||||
Str::startsWith($originalProduct->name, $copyOf) ? '' : $copyOf,
|
||||
$originalProduct->name,
|
||||
$randomSuffix
|
||||
);
|
||||
|
|
@ -623,13 +625,14 @@ class ProductRepository extends Repository
|
|||
}
|
||||
|
||||
if ($oldValue->attribute_id === $attributeIds['url_key']) {
|
||||
$copiedSlug = sprintf('%s-%s-%s',
|
||||
trans('admin::app.copy-of'),
|
||||
$copyOfSlug = trans('admin::app.copy-of-slug');
|
||||
$copiedSlug = sprintf('%s%s-%s',
|
||||
Str::startsWith($originalProduct->url_key, $copyOfSlug) ? '' : $copyOfSlug,
|
||||
$originalProduct->url_key,
|
||||
$randomSuffix
|
||||
);
|
||||
$newValue->text_value = __('admin::app.copy-of-slug') . '-' . $originalProduct->url_key . '-' . $randomSuffix;
|
||||
$newProductFlat->url_key = __('admin::app.copy-of-slug') . '-' . $originalProduct->url_key . '-' . $randomSuffix;
|
||||
$newValue->text_value = $copiedSlug;
|
||||
$newProductFlat->url_key = $copiedSlug;
|
||||
}
|
||||
|
||||
if ($oldValue->attribute_id === $attributeIds['sku']) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue