From 705350f932181550b6042ed60cbc69e9d3c21baf Mon Sep 17 00:00:00 2001 From: Poghos Boyajyan <44973047+k3rnel@users.noreply.github.com> Date: Fri, 15 Jan 2021 17:05:10 +0400 Subject: [PATCH 1/5] Added condition that allow to use repository in console mode --- packages/Webkul/Product/src/Type/Configurable.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/Webkul/Product/src/Type/Configurable.php b/packages/Webkul/Product/src/Type/Configurable.php index 9236a85cf..d7f1b7276 100644 --- a/packages/Webkul/Product/src/Type/Configurable.php +++ b/packages/Webkul/Product/src/Type/Configurable.php @@ -96,7 +96,7 @@ class Configurable extends AbstractType { $product = parent::update($data, $id, $attribute); - if (request()->route()->getName() != 'admin.catalog.products.massupdate') { + if (app()->runningInConsole() || request()->route()->getName() != 'admin.catalog.products.massupdate') { $previousVariantIds = $product->variants->pluck('id'); if (isset($data['variants'])) { @@ -660,4 +660,4 @@ class Configurable extends AbstractType return $total; } -} \ No newline at end of file +} From c7411ce00b55e2b9c70171c8a88f42d7c8b132f0 Mon Sep 17 00:00:00 2001 From: Poghos Boyajyan <44973047+k3rnel@users.noreply.github.com> Date: Mon, 25 Jan 2021 17:58:43 +0400 Subject: [PATCH 2/5] Added checking for the route existence in request --- packages/Webkul/Product/src/Type/Configurable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/Webkul/Product/src/Type/Configurable.php b/packages/Webkul/Product/src/Type/Configurable.php index d7f1b7276..d3ccbcc55 100644 --- a/packages/Webkul/Product/src/Type/Configurable.php +++ b/packages/Webkul/Product/src/Type/Configurable.php @@ -96,7 +96,7 @@ class Configurable extends AbstractType { $product = parent::update($data, $id, $attribute); - if (app()->runningInConsole() || request()->route()->getName() != 'admin.catalog.products.massupdate') { + if (request()->route() && request()->route()->getName() != 'admin.catalog.products.massupdate') { $previousVariantIds = $product->variants->pluck('id'); if (isset($data['variants'])) { From beb1fbf4091e03df172e0f253ae4e84777e124a9 Mon Sep 17 00:00:00 2001 From: Poghos Boyajyan <44973047+k3rnel@users.noreply.github.com> Date: Mon, 25 Jan 2021 17:59:52 +0400 Subject: [PATCH 3/5] Added checking for the route existence in request --- packages/Webkul/Product/src/Type/Configurable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/Webkul/Product/src/Type/Configurable.php b/packages/Webkul/Product/src/Type/Configurable.php index d3ccbcc55..6744f9a8b 100644 --- a/packages/Webkul/Product/src/Type/Configurable.php +++ b/packages/Webkul/Product/src/Type/Configurable.php @@ -96,7 +96,7 @@ class Configurable extends AbstractType { $product = parent::update($data, $id, $attribute); - if (request()->route() && request()->route()->getName() != 'admin.catalog.products.massupdate') { + if (!request()->route() || request()->route()->getName() != 'admin.catalog.products.massupdate') { $previousVariantIds = $product->variants->pluck('id'); if (isset($data['variants'])) { From 203483a5c02971029ae5b3d6a25e6c59860bfde4 Mon Sep 17 00:00:00 2001 From: Poghos Boyajyan <44973047+k3rnel@users.noreply.github.com> Date: Mon, 25 Jan 2021 18:13:40 +0400 Subject: [PATCH 4/5] Added checking for the route existence in request --- packages/Webkul/Product/src/Type/Configurable.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/Webkul/Product/src/Type/Configurable.php b/packages/Webkul/Product/src/Type/Configurable.php index 6744f9a8b..c0b27c972 100644 --- a/packages/Webkul/Product/src/Type/Configurable.php +++ b/packages/Webkul/Product/src/Type/Configurable.php @@ -95,8 +95,9 @@ class Configurable extends AbstractType public function update(array $data, $id, $attribute = "id") { $product = parent::update($data, $id, $attribute); - - if (!request()->route() || request()->route()->getName() != 'admin.catalog.products.massupdate') { + $route = request()->route() ? request()->route()->getName() : ''; + + if ($route != 'admin.catalog.products.massupdate') { $previousVariantIds = $product->variants->pluck('id'); if (isset($data['variants'])) { From a6cacb93da80e5b8facac3a9b674aa0028652a54 Mon Sep 17 00:00:00 2001 From: Poghos Date: Mon, 25 Jan 2021 18:32:26 +0400 Subject: [PATCH 5/5] Added checking for the route existence for Bundle, Downloadable, Grouped types. --- packages/Webkul/Product/src/Type/Bundle.php | 5 +++-- packages/Webkul/Product/src/Type/Downloadable.php | 5 +++-- packages/Webkul/Product/src/Type/Grouped.php | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/Webkul/Product/src/Type/Bundle.php b/packages/Webkul/Product/src/Type/Bundle.php index 4c8709763..a179d5efe 100644 --- a/packages/Webkul/Product/src/Type/Bundle.php +++ b/packages/Webkul/Product/src/Type/Bundle.php @@ -132,8 +132,9 @@ class Bundle extends AbstractType public function update(array $data, $id, $attribute = "id") { $product = parent::update($data, $id, $attribute); + $route = request()->route() ? request()->route()->getName() : ''; - if (request()->route()->getName() != 'admin.catalog.products.massupdate') { + if ($route != 'admin.catalog.products.massupdate') { $this->productBundleOptionRepository->saveBundleOptons($data, $product); } @@ -765,4 +766,4 @@ class Bundle extends AbstractType return true; } -} \ No newline at end of file +} diff --git a/packages/Webkul/Product/src/Type/Downloadable.php b/packages/Webkul/Product/src/Type/Downloadable.php index e8cf7741f..6dab992d3 100644 --- a/packages/Webkul/Product/src/Type/Downloadable.php +++ b/packages/Webkul/Product/src/Type/Downloadable.php @@ -122,8 +122,9 @@ class Downloadable extends AbstractType public function update(array $data, $id, $attribute = "id") { $product = parent::update($data, $id, $attribute); + $route = request()->route() ? request()->route()->getName() : ''; - if (request()->route()->getName() != 'admin.catalog.products.massupdate') { + if ($route != 'admin.catalog.products.massupdate') { $this->productDownloadableLinkRepository->saveLinks($data, $product); $this->productDownloadableSampleRepository->saveSamples($data, $product); @@ -291,4 +292,4 @@ class Downloadable extends AbstractType return $result; } -} \ No newline at end of file +} diff --git a/packages/Webkul/Product/src/Type/Grouped.php b/packages/Webkul/Product/src/Type/Grouped.php index 1f7f1c42d..b083d2112 100644 --- a/packages/Webkul/Product/src/Type/Grouped.php +++ b/packages/Webkul/Product/src/Type/Grouped.php @@ -96,8 +96,9 @@ class Grouped extends AbstractType public function update(array $data, $id, $attribute = "id") { $product = parent::update($data, $id, $attribute); + $route = request()->route() ? request()->route()->getName() : ''; - if (request()->route()->getName() != 'admin.catalog.products.massupdate') { + if ($route != 'admin.catalog.products.massupdate') { $this->productGroupedProductRepository->saveGroupedProducts($data, $product); } @@ -235,4 +236,4 @@ class Grouped extends AbstractType return $products; } -} \ No newline at end of file +}