Override Shop route to give main HomesController Route back control

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
rhand
Posts: 23
Joined: 12 Apr 2024, 03:06

Override Shop route to give main HomesController Route back control

Post by rhand » 31 May 2024, 00:13

Now I need to see how I can load the view for the domein.nl shop in the backend. When I check the routes for Aimeos based routes I get these:

Code: Select all

php artisan route:list
GET|POST|HEAD   / ................................................................................................. aimeos_home › Aimeos\Shop › CatalogController@homeAction
...
POST            admin/{site}/graphql ................................................................ aimeos_shop_graphql_post › Aimeos\Shop › GraphqlController@indexAction
  POST            admin/{site}/jqadm/batch/{resource} .................................................... aimeos_shop_jqadm_batch › Aimeos\Shop › JqadmController@batchAction
  GET|POST|HEAD   admin/{site}/jqadm/copy/{resource}/{id} .................................................. aimeos_shop_jqadm_copy › Aimeos\Shop › JqadmController@copyAction
  GET|POST|HEAD   admin/{site}/jqadm/create/{resource} ................................................. aimeos_shop_jqadm_create › Aimeos\Shop › JqadmController@createAction
  POST            admin/{site}/jqadm/delete/{resource}/{id?} ........................................... aimeos_shop_jqadm_delete › Aimeos\Shop › JqadmController@deleteAction
  GET|POST|HEAD   admin/{site}/jqadm/export/{resource} ................................................. aimeos_shop_jqadm_export › Aimeos\Shop › JqadmController@exportAction
  GET|HEAD        admin/{site}/jqadm/file/{type} ........................................................... aimeos_shop_jqadm_file › Aimeos\Shop › JqadmController@fileAction
  GET|HEAD        admin/{site}/jqadm/get/{resource}/{id} ..................................................... aimeos_shop_jqadm_get › Aimeos\Shop › JqadmController@getAction
  POST            admin/{site}/jqadm/import/{resource} ................................................. aimeos_shop_jqadm_import › Aimeos\Shop › JqadmController@importAction
  POST            admin/{site}/jqadm/save/{resource} ....................................................... aimeos_shop_jqadm_save › Aimeos\Shop › JqadmController@saveAction
  GET|POST|HEAD   admin/{site}/jqadm/search/{resource} ................................................. aimeos_shop_jqadm_search › Aimeos\Shop › JqadmController@searchAction
  OPTIONS         admin/{site}/jsonadm/{resource?} ............................................... aimeos_shop_jsonadm_options › Aimeos\Shop › JsonadmController@optionsAction
  DELETE          admin/{site}/jsonadm/{resource}/{id?} ............................................ aimeos_shop_jsonadm_delete › Aimeos\Shop › JsonadmController@deleteAction
  GET|HEAD        admin/{site}/jsonadm/{resource}/{id?} .................................................. aimeos_shop_jsonadm_get › Aimeos\Shop › JsonadmController@getAction
  PATCH           admin/{site}/jsonadm/{resource}/{id?} .............................................. aimeos_shop_jsonadm_patch › Aimeos\Shop › JsonadmController@patchAction
  POST            admin/{site}/jsonadm/{resource}/{id?} ................................................ aimeos_shop_jsonadm_post › Aimeos\Shop › JsonadmController@postAction
  PUT             admin/{site}/jsonadm/{resource}/{id?} .................................................. aimeos_shop_jsonadm_put › Aimeos\Shop › JsonadmController@putAction
  GET|HEAD        api/extend-module/{type}/component .......................................................................... Published\ModulesController@getExtendComponent
...
GET|OPTIONS|HEAD jsonapi/{resource?} ........................................................... aimeos_shop_jsonapi_options › Aimeos\Shop › JsonapiController@optionsAction
  DELETE          jsonapi/{resource} ............................................................... aimeos_shop_jsonapi_delete › Aimeos\Shop › JsonapiController@deleteAction
  GET|HEAD        jsonapi/{resource} ..................................................................... aimeos_shop_jsonapi_get › Aimeos\Shop › JsonapiController@getAction
  PATCH           jsonapi/{resource} ................................................................. aimeos_shop_jsonapi_patch › Aimeos\Shop › JsonapiController@patchAction
  POST            jsonapi/{resource} ................................................................... aimeos_shop_jsonapi_post › Aimeos\Shop › JsonapiController@postAction
  PUT             jsonapi/{resource} ..................................................................... aimeos_shop_jsonapi_put › Aimeos\Shop › JsonapiController@putAction
   ...
  GET|POST|HEAD   profile .................................................................................. aimeos_shop_account › Aimeos\Shop › AccountController@indexAction
  GET|POST|HEAD   profile/download/{dl_id} ..................................................... aimeos_shop_account_download › Aimeos\Shop › AccountController@downloadAction
  GET|POST|HEAD   profile/favorite/{fav_action?}/{fav_id?}/{d_name?}/{d_pos?} ..................... aimeos_shop_account_favorite › Aimeos\Shop › AccountController@indexAction
  GET|POST|HEAD   profile/watch/{wat_action?}/{wat_id?}/{d_name?}/{d_pos?} ........................... aimeos_shop_account_watch › Aimeos\Shop › AccountController@indexAction
  ...
GET|POST|HEAD   shop ......................................................................................... aimeos_shop_list › Aimeos\Shop › CatalogController@listAction
  GET|POST|HEAD   shop/basket ................................................................................ aimeos_shop_basket › Aimeos\Shop › BasketController@indexAction
  GET|POST|HEAD   shop/checkout/{c_step?} ................................................................ aimeos_shop_checkout › Aimeos\Shop › CheckoutController@indexAction
  GET|POST|HEAD   shop/confirm/{code?} .................................................................. aimeos_shop_confirm › Aimeos\Shop › CheckoutController@confirmAction
  GET|POST|HEAD   shop/count ................................................................................. aimeos_shop_count › Aimeos\Shop › CatalogController@countAction
  GET|POST|HEAD   shop/pin ........................................................................ aimeos_shop_session_pinned › Aimeos\Shop › CatalogController@sessionAction
  GET|POST|HEAD   shop/stock ................................................................................. aimeos_shop_stock › Aimeos\Shop › CatalogController@stockAction
  GET|POST|HEAD   shop/suggest ........................................................................... aimeos_shop_suggest › Aimeos\Shop › CatalogController@suggestAction
  GET|POST|HEAD   shop/{d_name}/{d_pos?}/{d_prodid?} ....................................................... aimeos_shop_detail › Aimeos\Shop › CatalogController@detailAction
  GET|POST|HEAD   shop/{f_name}~{f_catid}/{l_page?} ............................................................ aimeos_shop_tree › Aimeos\Shop › CatalogController@treeAction
 ...
 GET|POST|HEAD   supplier/{s_name}/{f_supid} ........................................................... aimeos_shop_supplier › Aimeos\Shop › SupplierController@detailAction
...
GET|POST|HEAD   update .................................................................................. aimeos_shop_update › Aimeos\Shop › CheckoutController@updateAction
I would like to override the home route as it seems to override

Code: Select all

GET|HEAD        
GET|POST|HEAD   / ................................................................................................. aimeos_home › Aimeos\Shop › CatalogController@homeAction
  GET|HEAD        smtv.test/ ........................................................................................................................... HomesController@index
So I tried adding

Code: Select all

...
Route::domain(config('name.app_domain'))->group(function () {
    Route::get('/sitemap.xml', [Published\SiteController::class, 'generateSitemap']);
Route::match( array( 'GET', 'POST' ), '/', array(
        'as' => 'aimeos_home',
        // 'uses' => 'Aimeos\Shop\Controller\CatalogController@homeAction'
        'uses' => 'App\Http\Controllers\HomesController@index'
    ) )->where( ['locale' => '[a-z]{2}(\_[A-Z]{2})?', 'site' => '[A-Za-z0-9\.\-]+'] );
    Route::get('/', [HomesController::class, 'index']);
...
and cleared route cache and reloaded list, but it does not seem to help as of yet.

Also wonder if there is a way to just copy over routes to web.php so we have all there and can manipulate them like I did with Jetstream and Fortify . Now there are two places to look for routes and the Aimeos one is at vendor/aimeos/aimeos-laravel/routes/aimeos.php

Basically I want to turn off all Aimeos frontend routes as we want to use our own. That and only use admin route overrides and JSON calls (get data into Vue components). This override is just one look at things.

rhand
Posts: 23
Joined: 12 Apr 2024, 03:06

Re: Override Shop route to give main HomesController Route back control

Post by rhand » 31 May 2024, 01:13

I turned off home in shop.php

Code: Select all

 'routes' => [
        ...
        // 'default' => ['prefix' => 'shop', 'middleware' => ['web']],
        // 'confirm' => ['prefix' => 'shop', 'middleware' => ['web']],
        // 'supplier' => ['prefix' => 's', 'middleware' => ['web']],
        // 'page' => ['prefix' => 'p', 'middleware' => ['web']],
        // 'home' => ['middleware' => ['web']],
        'home' => false,
        // 'update' => [],
    ],
    ...
    
then I did

Code: Select all

 
php artisan config: cache
php artisan route:clear
Then the home route got turned off. I had to cache configuration again as I updated shop.php config file. I forgot. Now I need to see how I can turn off all other frontend routes as I want to load product data, checkout, cart data into Vue components.

rhand
Posts: 23
Joined: 12 Apr 2024, 03:06

Re: Override Shop route to give main HomesController Route back control

Post by rhand » 31 May 2024, 02:25

Code: Select all

php artisan route:list --path=shop   

  GET|POST|HEAD       shop ..................................................................................... aimeos_shop_list › Aimeos\Shop › CatalogController@listAction
  GET|POST|HEAD       shop/basket ............................................................................ aimeos_shop_basket › Aimeos\Shop › BasketController@indexAction
  GET|POST|HEAD       shop/checkout/{c_step?} ............................................................ aimeos_shop_checkout › Aimeos\Shop › CheckoutController@indexAction
  GET|POST|HEAD       shop/confirm/{code?} .............................................................. aimeos_shop_confirm › Aimeos\Shop › CheckoutController@confirmAction
  GET|POST|HEAD       shop/count ............................................................................. aimeos_shop_count › Aimeos\Shop › CatalogController@countAction
  GET|POST|HEAD       shop/pin .................................................................... aimeos_shop_session_pinned › Aimeos\Shop › CatalogController@sessionAction
  GET|POST|HEAD       shop/stock ............................................................................. aimeos_shop_stock › Aimeos\Shop › CatalogController@stockAction
  GET|POST|HEAD       shop/suggest ....................................................................... aimeos_shop_suggest › Aimeos\Shop › CatalogController@suggestAction
  GET|POST|HEAD       shop/{d_name}/{d_pos?}/{d_prodid?} ................................................... aimeos_shop_detail › Aimeos\Shop › CatalogController@detailAction
  GET|POST|HEAD       shop/{f_name}~{f_catid}/{l_page?} ........................................................ aimeos_shop_tree › Aimeos\Shop › CatalogController@treeAction
  
  
also get removed using shop.php:

Code: Select all

// 'default' => ['prefix' => 'shop', 'middleware' => ['web']],
'default' => false,
// 'confirm' => ['prefix' => 'shop', 'middleware' => ['web']],
'confirm' => false,
So I think I am close or done with turning off frontend routes now.

User avatar
aimeos
Administrator
Posts: 8616
Joined: 01 Jan 1970, 00:00

Re: Override Shop route to give main HomesController Route back control

Post by aimeos » 02 Jun 2024, 06:52

You can turn off all route groups from Aimeos by setting them to "false" in the ./config/shop.php like you did. If you want to use a VueJS based PWA as frontend, use the JSON:API for interacting with Aimeos:
https://aimeos.org/docs/latest/frontend/jsonapi/
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply