From 54babf90798bf0e16fca866e1637aaf7b98d57fc Mon Sep 17 00:00:00 2001 From: Matt April Date: Sat, 26 Oct 2019 11:07:41 -0400 Subject: [PATCH 01/35] Moved ADMIN_MAIL_TO into mail config --- config/mail.php | 14 ++++++++++++++ .../Webkul/Admin/src/Mail/NewAdminNotification.php | 2 +- .../views/emails/sales/new-admin-order.blade.php | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/config/mail.php b/config/mail.php index 6b4631bf2..677ed43cd 100755 --- a/config/mail.php +++ b/config/mail.php @@ -60,6 +60,20 @@ return [ 'name' => env('MAIL_FROM_NAME') ], + /* + |-------------------------------------------------------------------------- + | Global "Admin" Address + |-------------------------------------------------------------------------- + | + | General admin related admins, such as order notifications. + | + */ + + 'admin' => [ + 'address' => env('ADMIN_MAIL_TO'), + 'name' => env('ADMIN_MAIL_NAME', 'Admin') + ], + /* |-------------------------------------------------------------------------- | E-Mail Encryption Protocol diff --git a/packages/Webkul/Admin/src/Mail/NewAdminNotification.php b/packages/Webkul/Admin/src/Mail/NewAdminNotification.php index fa9d5d199..b31a4ab1c 100644 --- a/packages/Webkul/Admin/src/Mail/NewAdminNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewAdminNotification.php @@ -42,7 +42,7 @@ class NewAdminNotification extends Mailable */ public function build() { - return $this->to(env('ADMIN_MAIL_TO')) + return $this->to(config('mail.admin.address')) ->subject(trans('shop::app.mail.order.subject')) ->view('shop::emails.sales.new-admin-order'); } diff --git a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-admin-order.blade.php b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-admin-order.blade.php index 1fadcec7e..2d0610236 100644 --- a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-admin-order.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-admin-order.blade.php @@ -185,7 +185,7 @@

{!! __('shop::app.mail.order.help', [ - 'support_email' => '' . env('ADMIN_MAIL_TO'). '' + 'support_email' => '' . config('mail.admin.address') . '' ]) !!}

From 3ebdde7681e4091583b0e2b40d82c0ab488d9ad2 Mon Sep 17 00:00:00 2001 From: Matt April Date: Sat, 26 Oct 2019 11:09:46 -0400 Subject: [PATCH 02/35] Replaced direct env references of MAIL_SHOP_FROM with config file references. Also enabled optional usage of MAIL_FROM_NAME. --- packages/Webkul/Admin/src/Mail/NewInvoiceNotification.php | 2 +- packages/Webkul/Admin/src/Mail/NewOrderNotification.php | 2 +- packages/Webkul/Admin/src/Mail/NewRefundNotification.php | 2 +- packages/Webkul/Admin/src/Mail/NewShipmentNotification.php | 2 +- packages/Webkul/Customer/src/Mail/RegistrationEmail.php | 2 +- packages/Webkul/Customer/src/Mail/VerificationEmail.php | 2 +- .../Webkul/Customer/src/Notifications/CustomerResetPassword.php | 2 +- packages/Webkul/Shop/src/Mail/SubscriptionEmail.php | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/Webkul/Admin/src/Mail/NewInvoiceNotification.php b/packages/Webkul/Admin/src/Mail/NewInvoiceNotification.php index a816d0d05..c5f833aea 100755 --- a/packages/Webkul/Admin/src/Mail/NewInvoiceNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewInvoiceNotification.php @@ -45,7 +45,7 @@ class NewInvoiceNotification extends Mailable $order = $this->invoice->order; return $this->to($order->customer_email, $order->customer_full_name) - ->from(env('SHOP_MAIL_FROM')) + ->from(config('mail.from')) ->subject(trans('shop::app.mail.invoice.subject', ['order_id' => $order->increment_id])) ->view('shop::emails.sales.new-invoice'); } diff --git a/packages/Webkul/Admin/src/Mail/NewOrderNotification.php b/packages/Webkul/Admin/src/Mail/NewOrderNotification.php index c53782ac7..2298d1463 100755 --- a/packages/Webkul/Admin/src/Mail/NewOrderNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewOrderNotification.php @@ -42,7 +42,7 @@ class NewOrderNotification extends Mailable public function build() { return $this->to($this->order->customer_email, $this->order->customer_full_name) - ->from(env('SHOP_MAIL_FROM')) + ->from(config('mail.from')) ->subject(trans('shop::app.mail.order.subject')) ->view('shop::emails.sales.new-order'); } diff --git a/packages/Webkul/Admin/src/Mail/NewRefundNotification.php b/packages/Webkul/Admin/src/Mail/NewRefundNotification.php index e682d10b0..8c4d9602f 100644 --- a/packages/Webkul/Admin/src/Mail/NewRefundNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewRefundNotification.php @@ -45,7 +45,7 @@ class NewRefundNotification extends Mailable $order = $this->refund->order; return $this->to($order->customer_email, $order->customer_full_name) - ->from(env('SHOP_MAIL_FROM')) + ->from(config('mail.from')) ->subject(trans('shop::app.mail.refund.subject', ['order_id' => $order->increment_id])) ->view('shop::emails.sales.new-refund'); } diff --git a/packages/Webkul/Admin/src/Mail/NewShipmentNotification.php b/packages/Webkul/Admin/src/Mail/NewShipmentNotification.php index 1a90aa5f9..9f1140281 100755 --- a/packages/Webkul/Admin/src/Mail/NewShipmentNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewShipmentNotification.php @@ -45,7 +45,7 @@ class NewShipmentNotification extends Mailable $order = $this->shipment->order; return $this->to($order->customer_email, $order->customer_full_name) - ->from(env('SHOP_MAIL_FROM')) + ->from(config('mail.from')) ->subject(trans('shop::app.mail.shipment.subject', ['order_id' => $order->increment_id])) ->view('shop::emails.sales.new-shipment'); } diff --git a/packages/Webkul/Customer/src/Mail/RegistrationEmail.php b/packages/Webkul/Customer/src/Mail/RegistrationEmail.php index ffd045e90..a93424b53 100644 --- a/packages/Webkul/Customer/src/Mail/RegistrationEmail.php +++ b/packages/Webkul/Customer/src/Mail/RegistrationEmail.php @@ -31,7 +31,7 @@ class RegistrationEmail extends Mailable public function build() { return $this->to($this->data['email']) - ->from(env('SHOP_MAIL_FROM')) + ->from(config('mail.from')) ->subject(trans('shop::app.mail.customer.registration.customer-registration')) ->view('shop::emails.customer.registration')->with('data', $this->data); } diff --git a/packages/Webkul/Customer/src/Mail/VerificationEmail.php b/packages/Webkul/Customer/src/Mail/VerificationEmail.php index 9091d7afc..6f987bd3b 100755 --- a/packages/Webkul/Customer/src/Mail/VerificationEmail.php +++ b/packages/Webkul/Customer/src/Mail/VerificationEmail.php @@ -31,7 +31,7 @@ class VerificationEmail extends Mailable public function build() { return $this->to($this->verificationData['email']) - ->from(env('SHOP_MAIL_FROM')) + ->from(config('mail.from')) ->subject(trans('shop::app.mail.customer.verification.subject')) ->view('shop::emails.customer.verification-email')->with('data', ['email' => $this->verificationData['email'], 'token' => $this->verificationData['token']]); } diff --git a/packages/Webkul/Customer/src/Notifications/CustomerResetPassword.php b/packages/Webkul/Customer/src/Notifications/CustomerResetPassword.php index 1f8b39858..ddb4e1956 100755 --- a/packages/Webkul/Customer/src/Notifications/CustomerResetPassword.php +++ b/packages/Webkul/Customer/src/Notifications/CustomerResetPassword.php @@ -21,7 +21,7 @@ class CustomerResetPassword extends ResetPassword } return (new MailMessage) - ->from(env('SHOP_MAIL_FROM')) + ->from(config('mail.from')) ->subject(__('shop::app.mail.forget-password.subject') ) ->view('shop::emails.customer.forget-password', [ 'user_name' => $notifiable->name, diff --git a/packages/Webkul/Shop/src/Mail/SubscriptionEmail.php b/packages/Webkul/Shop/src/Mail/SubscriptionEmail.php index 96ba6a3e3..271cb6f85 100755 --- a/packages/Webkul/Shop/src/Mail/SubscriptionEmail.php +++ b/packages/Webkul/Shop/src/Mail/SubscriptionEmail.php @@ -31,7 +31,7 @@ class SubscriptionEmail extends Mailable public function build() { return $this->to($this->subscriptionData['email']) - ->from(env('SHOP_MAIL_FROM')) + ->from(config('mail.from')) ->subject(trans('shop::app.mail.customer.subscription.subject')) ->view('shop::emails.customer.subscription-email')->with('data', ['content' => 'You Are Subscribed', 'token' => $this->subscriptionData['token']]); } From 25c2a15b65ff9d9d5ddbea573dfbf3ae44fbb9cc Mon Sep 17 00:00:00 2001 From: Mona Hartdegen Date: Thu, 21 Nov 2019 17:14:53 +0100 Subject: [PATCH 03/35] introduced url structure for categories and products (SEO improvements) --- .../src/Repositories/CategoryRepository.php | 18 ++++ .../Http/Controllers/WishlistController.php | 4 +- ...lumn_url_path_to_category_translations.php | 32 ++++++ ...d_function_to_get_url_path_of_category.php | 65 ++++++++++++ ...7_add_trigger_to_category_translations.php | 99 +++++++++++++++++++ ...path_to_existing_category_translations.php | 44 +++++++++ ...11_21_194703_add_trigger_to_categories.php | 66 +++++++++++++ .../src/Http/Controllers/CartController.php | 2 +- .../Http/Controllers/CategoryController.php | 13 --- .../Http/Controllers/ProductController.php | 15 --- .../ProductsCategoriesProxyController.php | 92 +++++++++++++++++ packages/Webkul/Shop/src/Http/routes.php | 18 ++-- .../src/Providers/ShopServiceProvider.php | 2 + .../views/layouts/footer/footer.blade.php | 2 +- .../views/products/list/card.blade.php | 4 +- .../views/products/reviews/create.blade.php | 4 +- .../views/products/reviews/index.blade.php | 4 +- tests/Browser/ProductCategoryTest.php | 2 +- 18 files changed, 437 insertions(+), 49 deletions(-) create mode 100644 packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194541_add_column_url_path_to_category_translations.php create mode 100644 packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194608_add_stored_function_to_get_url_path_of_category.php create mode 100644 packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194627_add_trigger_to_category_translations.php create mode 100644 packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194648_add_url_path_to_existing_category_translations.php create mode 100644 packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194703_add_trigger_to_categories.php create mode 100644 packages/Webkul/Shop/src/Http/Controllers/ProductsCategoriesProxyController.php diff --git a/packages/Webkul/Category/src/Repositories/CategoryRepository.php b/packages/Webkul/Category/src/Repositories/CategoryRepository.php index e6380d55f..21fd1c686 100755 --- a/packages/Webkul/Category/src/Repositories/CategoryRepository.php +++ b/packages/Webkul/Category/src/Repositories/CategoryRepository.php @@ -151,6 +151,24 @@ class CategoryRepository extends Repository ); } + /** + * @param string $urlPath + * + * @return mixed + */ + public function findByPathOrFail(string $urlPath) + { + $category = $this->model->whereTranslation('url_path', $urlPath)->first(); + + if ($category) { + return $category; + } + + throw (new ModelNotFoundException)->setModel( + get_class($this->model), $urlPath + ); + } + /** * @param array $data * @param $id diff --git a/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php b/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php index 24790355f..590bbebb6 100755 --- a/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php +++ b/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php @@ -166,14 +166,14 @@ class WishlistController extends Controller } else { session()->flash('info', trans('shop::app.wishlist.option-missing')); - return redirect()->route('shop.products.index', $wishlistItem->product->url_key); + return redirect()->route('shop.productOrCategory.index', $wishlistItem->product->url_key); } return redirect()->back(); } catch (\Exception $e) { session()->flash('warning', $e->getMessage()); - return redirect()->route('shop.products.index', ['slug' => $wishlistItem->product->url_key]); + return redirect()->route('shop.productOrCategory.index', ['slug' => $wishlistItem->product->url_key]); } } diff --git a/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194541_add_column_url_path_to_category_translations.php b/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194541_add_column_url_path_to_category_translations.php new file mode 100644 index 000000000..167f43056 --- /dev/null +++ b/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194541_add_column_url_path_to_category_translations.php @@ -0,0 +1,32 @@ +string('url_path'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('category_translations', function (Blueprint $table) { + $table->dropColumn('url_path'); + }); + } +} diff --git a/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194608_add_stored_function_to_get_url_path_of_category.php b/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194608_add_stored_function_to_get_url_path_of_category.php new file mode 100644 index 000000000..1470a4b43 --- /dev/null +++ b/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194608_add_stored_function_to_get_url_path_of_category.php @@ -0,0 +1,65 @@ += parent._lft + AND node._rgt <= parent._rgt + AND node.id = categoryId + AND parent.id <> 1 + GROUP BY + node.id; + + IF urlPath IS NULL + THEN + SET urlPath = (SELECT slug FROM category_translations WHERE category_translations.category_id = categoryId); + END IF; + ELSE + SET urlPath = ''; + END IF; + + RETURN urlPath; + END; +SQL; + + DB::unprepared($functionSQL); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + DB::unprepared('DROP FUNCTION IF EXISTS `get_url_path_of_category`;'); + } +} diff --git a/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194627_add_trigger_to_category_translations.php b/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194627_add_trigger_to_category_translations.php new file mode 100644 index 000000000..8004d61c8 --- /dev/null +++ b/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194627_add_trigger_to_category_translations.php @@ -0,0 +1,99 @@ +getTriggerBody('insert'); + $insertTrigger = <<< SQL + CREATE TRIGGER %s + BEFORE INSERT ON category_translations + FOR EACH ROW + BEGIN + $insertTriggerBody + END; +SQL; + + $updateTriggerBody = $this->getTriggerBody(); + $updateTrigger = <<< SQL + CREATE TRIGGER %s + BEFORE UPDATE ON category_translations + FOR EACH ROW + BEGIN + $updateTriggerBody + END; +SQL; + + DB::unprepared(sprintf('DROP TRIGGER IF EXISTS %s;', self::TRIGGER_NAME_INSERT)); + DB::unprepared(sprintf($insertTrigger, self::TRIGGER_NAME_INSERT)); + + DB::unprepared(sprintf('DROP TRIGGER IF EXISTS %s;', self::TRIGGER_NAME_UPDATE)); + DB::unprepared(sprintf($updateTrigger, self::TRIGGER_NAME_UPDATE)); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + DB::unprepared(sprintf('DROP TRIGGER IF EXISTS %s;', self::TRIGGER_NAME_INSERT)); + DB::unprepared(sprintf('DROP TRIGGER IF EXISTS %s;', self::TRIGGER_NAME_UPDATE)); + } + + /** + * Returns trigger body as string based on type ('update' or 'insert'). + * + * @param string $type + * + * @return string + */ + private function getTriggerBody(string $type = 'update'): string + { + $addOnInsert = ($type === 'update') ? '' : <<< SQL + ELSE + SELECT CONCAT(urlPath, '/', NEW.slug) INTO urlPath; +SQL; + + return <<< SQL + DECLARE urlPath varchar(255); + + IF NEW.category_id != 1 + THEN + SELECT + GROUP_CONCAT(parent_translations.slug SEPARATOR '/') INTO urlPath + FROM + categories AS node, + categories AS parent + JOIN category_translations AS parent_translations ON parent.id = parent_translations.category_id + WHERE + node._lft >= parent._lft + AND node._rgt <= parent._rgt + AND node.id = NEW.category_id + AND parent.id <> 1 + GROUP BY + node.id; + + IF urlPath IS NULL + THEN + SET urlPath = NEW.slug; + $addOnInsert + END IF; + + SET NEW.url_path = urlPath; + END IF; +SQL; + } +} diff --git a/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194648_add_url_path_to_existing_category_translations.php b/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194648_add_url_path_to_existing_category_translations.php new file mode 100644 index 000000000..accaf674f --- /dev/null +++ b/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194648_add_url_path_to_existing_category_translations.php @@ -0,0 +1,44 @@ += parent._lft + AND node._rgt <= parent._rgt + AND node.id = :category_id + AND node.id <> 1 + AND parent.id <> 1 + GROUP BY + node.id +SQL; + + $categoryTranslationsTableName = app(CategoryTranslation::class)->getTable(); + + foreach (DB::table($categoryTranslationsTableName)->get() as $categoryTranslation) { + $urlPathQueryResult = DB::selectOne($sql, ['category_id' => $categoryTranslation->category_id]); + $url_path = $urlPathQueryResult ? $urlPathQueryResult->url_path : ''; + + DB::table($categoryTranslationsTableName) + ->where('id', $categoryTranslation->id) + ->update(['url_path' => $url_path]); + } + } +} diff --git a/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194703_add_trigger_to_categories.php b/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194703_add_trigger_to_categories.php new file mode 100644 index 000000000..e25243d64 --- /dev/null +++ b/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194703_add_trigger_to_categories.php @@ -0,0 +1,66 @@ +productRepository->find($id); - return redirect()->route('shop.products.index', ['slug' => $product->url_key]); + return redirect()->route('shop.productOrCategory.index', ['slug' => $product->url_key]); } return redirect()->back(); diff --git a/packages/Webkul/Shop/src/Http/Controllers/CategoryController.php b/packages/Webkul/Shop/src/Http/Controllers/CategoryController.php index 03d428067..69defe0a9 100755 --- a/packages/Webkul/Shop/src/Http/Controllers/CategoryController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/CategoryController.php @@ -38,17 +38,4 @@ class CategoryController extends Controller $this->_config = request('_config'); } - - /** - * Display a listing of the resource. - * - * @param string $slug - * @return \Illuminate\View\View - */ - public function index($slug) - { - $category = $this->categoryRepository->findBySlugOrFail($slug); - - return view($this->_config['view'], compact('category')); - } } diff --git a/packages/Webkul/Shop/src/Http/Controllers/ProductController.php b/packages/Webkul/Shop/src/Http/Controllers/ProductController.php index ef6144581..2f24b78e8 100755 --- a/packages/Webkul/Shop/src/Http/Controllers/ProductController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/ProductController.php @@ -79,21 +79,6 @@ class ProductController extends Controller $this->_config = request('_config'); } - /** - * Display a listing of the resource. - * - * @param string $slug - * @return \Illuminate\View\View - */ - public function index($slug) - { - $product = $this->productRepository->findBySlugOrFail($slug); - - $customer = auth()->guard('customer')->user(); - - return view($this->_config['view'], compact('product', 'customer')); - } - /** * Download image or file * diff --git a/packages/Webkul/Shop/src/Http/Controllers/ProductsCategoriesProxyController.php b/packages/Webkul/Shop/src/Http/Controllers/ProductsCategoriesProxyController.php new file mode 100644 index 000000000..7abca8acb --- /dev/null +++ b/packages/Webkul/Shop/src/Http/Controllers/ProductsCategoriesProxyController.php @@ -0,0 +1,92 @@ +categoryRepository = $categoryRepository; + $this->productRepository = $productRepository; + + $this->_config = request('_config'); + } + + /** + * Display a listing of the resource which can be a category or a product. + * + * + * @param string $slug + * + * @return \Illuminate\View\View + */ + public function index(string $slug) + { + $slug = rtrim($slug, '/ '); + + if (preg_match('/^([a-z-]+\/?)+$/', $slug)) { + + if (DB::table(app(CategoryTranslation::class)->getTable()) + ->where('url_path', '=', $slug) + ->exists() + ) { + + $category = $this->categoryRepository->findByPathOrFail($slug); + + return view($this->_config['category_view'], compact('category')); + } + + if (DB::table(app(ProductFlat::class)->getTable()) + ->where('url_key', '=', $slug) + ->exists() + ) { + $product = $this->productRepository->findBySlugOrFail($slug); + + $customer = auth()->guard('customer')->user(); + + return view($this->_config['product_view'], compact('product', 'customer')); + } + + } else { + throw new NotFoundHttpException(); + } + } +} \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Http/routes.php b/packages/Webkul/Shop/src/Http/routes.php index 1eb433e8e..c3c8601a3 100755 --- a/packages/Webkul/Shop/src/Http/routes.php +++ b/packages/Webkul/Shop/src/Http/routes.php @@ -13,11 +13,6 @@ Route::group(['middleware' => ['web', 'locale', 'theme', 'currency']], function //unsubscribe Route::get('/unsubscribe/{token}', 'Webkul\Shop\Http\Controllers\SubscriptionController@unsubscribe')->name('shop.unsubscribe'); - //Store front header nav-menu fetch - Route::get('/categories/{slug}', 'Webkul\Shop\Http\Controllers\CategoryController@index')->defaults('_config', [ - 'view' => 'shop::products.index' - ])->name('shop.categories.index'); - //Store front search Route::get('/search', 'Webkul\Shop\Http\Controllers\SearchController@index')->defaults('_config', [ 'view' => 'shop::search.search' @@ -89,11 +84,6 @@ Route::group(['middleware' => ['web', 'locale', 'theme', 'currency']], function //Shop buynow button action Route::get('move/wishlist/{id}', 'Webkul\Shop\Http\Controllers\CartController@moveToWishlist')->name('shop.movetowishlist'); - //Show Product Details Page(For individually Viewable Product) - Route::get('/products/{slug}', 'Webkul\Shop\Http\Controllers\ProductController@index')->defaults('_config', [ - 'view' => 'shop::products.view' - ])->name('shop.products.index'); - Route::get('/downloadable/download-sample/{type}/{id}', 'Webkul\Shop\Http\Controllers\ProductController@downloadSample')->name('shop.downloadable.download_sample'); // Show Product Review Form @@ -307,5 +297,13 @@ Route::group(['middleware' => ['web', 'locale', 'theme', 'currency']], function Route::get('page/{slug}', 'Webkul\CMS\Http\Controllers\Shop\PagePresenterController@presenter')->name('shop.cms.page'); + Route::get('{slug}', \Webkul\Shop\Http\Controllers\ProductsCategoriesProxyController::class . '@index') + ->defaults('_config', [ + 'product_view' => 'shop::products.view', + 'category_view' => 'shop::products.index' + ]) + ->where('slug', '^([a-z-]+\/?)+$') + ->name('shop.productOrCategory.index'); + Route::fallback('Webkul\Shop\Http\Controllers\HomeController@notFound'); }); diff --git a/packages/Webkul/Shop/src/Providers/ShopServiceProvider.php b/packages/Webkul/Shop/src/Providers/ShopServiceProvider.php index e97fd1d9d..06c0d1cee 100755 --- a/packages/Webkul/Shop/src/Providers/ShopServiceProvider.php +++ b/packages/Webkul/Shop/src/Providers/ShopServiceProvider.php @@ -25,6 +25,8 @@ class ShopServiceProvider extends ServiceProvider */ public function boot(Router $router) { + $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); + $this->loadRoutesFrom(__DIR__ . '/../Http/routes.php'); $this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'shop'); diff --git a/packages/Webkul/Shop/src/Resources/views/layouts/footer/footer.blade.php b/packages/Webkul/Shop/src/Resources/views/layouts/footer/footer.blade.php index a9ecdb554..fd541a7e9 100755 --- a/packages/Webkul/Shop/src/Resources/views/layouts/footer/footer.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/layouts/footer/footer.blade.php @@ -18,7 +18,7 @@ diff --git a/packages/Webkul/Shop/src/Resources/views/products/list/card.blade.php b/packages/Webkul/Shop/src/Resources/views/products/list/card.blade.php index c0d9f588c..6ccb3fdee 100755 --- a/packages/Webkul/Shop/src/Resources/views/products/list/card.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/list/card.blade.php @@ -13,7 +13,7 @@ @endif @@ -21,7 +21,7 @@
- + {{ $product->name }} diff --git a/packages/Webkul/Shop/src/Resources/views/products/reviews/create.blade.php b/packages/Webkul/Shop/src/Resources/views/products/reviews/create.blade.php index ad6b8365b..0ce797b32 100755 --- a/packages/Webkul/Shop/src/Resources/views/products/reviews/create.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/reviews/create.blade.php @@ -15,13 +15,13 @@ getProductBaseImage($product); ?> diff --git a/packages/Webkul/Shop/src/Resources/views/products/reviews/index.blade.php b/packages/Webkul/Shop/src/Resources/views/products/reviews/index.blade.php index 79a519a4b..329fbdff4 100755 --- a/packages/Webkul/Shop/src/Resources/views/products/reviews/index.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/reviews/index.blade.php @@ -17,13 +17,13 @@
diff --git a/tests/Browser/ProductCategoryTest.php b/tests/Browser/ProductCategoryTest.php index 4c8b2658b..6717e2941 100644 --- a/tests/Browser/ProductCategoryTest.php +++ b/tests/Browser/ProductCategoryTest.php @@ -41,7 +41,7 @@ class ProductCategoryTest extends DuskTestCase } $this->browse(function (Browser $browser) use($testSlug, $testProduct) { - $browser->visit(route('shop.categories.index', $testSlug)); + $browser->visit(route('shop.productOrCategory.index', $testSlug)); $browser->assertSeeLink($testProduct[0]['name']); $browser->pause(5000); }); From c57c5d9b6fb5a5c6b36b638968431c19a7cb56de Mon Sep 17 00:00:00 2001 From: MonaHartdegen Date: Fri, 22 Nov 2019 11:37:55 +0100 Subject: [PATCH 04/35] altered nav-menu to show correct category urls --- .../Resources/views/layouts/header/nav-menu/navmenu.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/Webkul/Shop/src/Resources/views/layouts/header/nav-menu/navmenu.blade.php b/packages/Webkul/Shop/src/Resources/views/layouts/header/nav-menu/navmenu.blade.php index c0e357257..be48e1767 100755 --- a/packages/Webkul/Shop/src/Resources/views/layouts/header/nav-menu/navmenu.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/layouts/header/nav-menu/navmenu.blade.php @@ -66,7 +66,7 @@ foreach (app('Webkul\Category\Repositories\CategoryRepository')->getVisibleCateg