From 803aa4a5479b8df2aa6ccc3c7d16af515edf10a2 Mon Sep 17 00:00:00 2001
From: Kevin Meijer <kevin@justbetter.nl>
Date: Tue, 8 Oct 2024 10:23:42 +0200
Subject: [PATCH 01/14] WIP site config

---
 src/RapidezStatamicServiceProvider.php | 27 ++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/src/RapidezStatamicServiceProvider.php b/src/RapidezStatamicServiceProvider.php
index 71700fe..c5af477 100644
--- a/src/RapidezStatamicServiceProvider.php
+++ b/src/RapidezStatamicServiceProvider.php
@@ -42,6 +42,7 @@ public function boot()
         $this
             ->bootCommands()
             ->bootConfig()
+            ->bootSites()
             ->bootRoutes()
             ->bootViews()
             ->bootListeners()
@@ -55,6 +56,32 @@ public function boot()
         Alternates::register();
     }
 
+    public function bootSites() : self
+    {
+        $sites = [];
+        $stores = Rapidez::getStores();
+
+        foreach ($stores as $store) {
+            $sites[$store['code']] = [
+                'name' => $store['name'] ?? $store['code'],
+                'locale' => '{{ config:rapidez.statamic.sites.' . $store['code'] . '.locale }}',
+                'lang' => '{{ config:rapidez.statamic.sites.' . $store['code'] . '.lang }}',
+                'url' => '{{ config:rapidez.statamic.sites.' . $store['code'] . '.url }}',
+                'attributes' => [
+                    'magento_store_id' => $store['store_id'],
+                    'group' => $store['website_code'] ?? '',
+                    'disabled' => '{{ config:rapidez.statamic.sites.' . $store['code'] . '.attributes.disabled }}',
+                ]
+            ];
+//            dd($store, $sites);
+        }
+
+        Site::setSites($sites);
+        Site::save();
+
+        return $this;
+    }
+
     public function bootCommands() : self
     {
         $this->commands([

From c2c5152ac882df9d472f93ffbd394d95c4b4ed38 Mon Sep 17 00:00:00 2001
From: Kevin Meijer <kevin@justbetter.nl>
Date: Thu, 17 Oct 2024 17:02:22 +0200
Subject: [PATCH 02/14] Cleaned up code

---
 src/RapidezStatamicServiceProvider.php | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/RapidezStatamicServiceProvider.php b/src/RapidezStatamicServiceProvider.php
index c5af477..289c897 100644
--- a/src/RapidezStatamicServiceProvider.php
+++ b/src/RapidezStatamicServiceProvider.php
@@ -73,7 +73,6 @@ public function bootSites() : self
                     'disabled' => '{{ config:rapidez.statamic.sites.' . $store['code'] . '.attributes.disabled }}',
                 ]
             ];
-//            dd($store, $sites);
         }
 
         Site::setSites($sites);

From 32917d4a2b23c374ea943c58200d514703cf276c Mon Sep 17 00:00:00 2001
From: Kevin Meijer <kevin@justbetter.nl>
Date: Thu, 17 Oct 2024 17:12:10 +0200
Subject: [PATCH 03/14] Removed old config & cleaned up code

---
 config/rapidez/statamic.php            | 3 ---
 src/RapidezStatamicServiceProvider.php | 3 +--
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/config/rapidez/statamic.php b/config/rapidez/statamic.php
index 0ff694b..33eabdf 100644
--- a/config/rapidez/statamic.php
+++ b/config/rapidez/statamic.php
@@ -80,13 +80,10 @@
 
     'sites' => [
         'default' => [
-            'name' => env('APP_NAME', 'Statamic'),
             'locale' => 'en_EN',
             'lang' => 'en_EN',
             'url' => '/',
             'attributes' => [
-                'magento_store_id' => 1,
-                'group' => 'default',
                 'disabled' => false,
             ],
         ],
diff --git a/src/RapidezStatamicServiceProvider.php b/src/RapidezStatamicServiceProvider.php
index 289c897..12c92e6 100644
--- a/src/RapidezStatamicServiceProvider.php
+++ b/src/RapidezStatamicServiceProvider.php
@@ -2,7 +2,6 @@
 
 namespace Rapidez\Statamic;
 
-use Statamic\Statamic;
 use Statamic\Sites\Sites;
 use Statamic\Facades\Site;
 use Statamic\Facades\Entry;
@@ -33,7 +32,7 @@ class RapidezStatamicServiceProvider extends ServiceProvider
     public function register()
     {
         $this->app->extend(Sites::class, function () {
-            return new SitesLinkedToMagentoStores(config('statamic.sites'));
+            return new SitesLinkedToMagentoStores();
         });
     }
 

From de3178224ca4b0ca6dd3bc8718cf39dd5a2bfa52 Mon Sep 17 00:00:00 2001
From: Kevin Meijer <kevin@justbetter.nl>
Date: Fri, 18 Oct 2024 12:45:39 +0200
Subject: [PATCH 04/14] Moved site creation to command & get all site data from
 Magento

---
 src/Commands/CreateSites.php           | 46 ++++++++++++++++++++++++++
 src/RapidezStatamicServiceProvider.php | 32 +++---------------
 2 files changed, 50 insertions(+), 28 deletions(-)
 create mode 100644 src/Commands/CreateSites.php

diff --git a/src/Commands/CreateSites.php b/src/Commands/CreateSites.php
new file mode 100644
index 0000000..87d4e0b
--- /dev/null
+++ b/src/Commands/CreateSites.php
@@ -0,0 +1,46 @@
+<?php
+
+namespace Rapidez\Statamic\Commands;
+
+use Statamic\Facades\Site;
+use Illuminate\Console\Command;
+use Rapidez\Core\Facades\Rapidez;
+
+class CreateSites extends Command
+{
+    protected $signature = 'rapidez:statamic:create:sites';
+
+    protected $description = 'Create sites based on the active Magento stores.';
+
+    public function handle(): int
+    {
+        $sites = [];
+        $stores = Rapidez::getStores();
+        $configModel = config('rapidez.models.config');
+
+        foreach ($stores as $store) {
+            Rapidez::setStore($store['store_id']);
+
+            $locale = $configModel::getCachedByPath('general/locale/code');
+            $lang = explode('_', $locale)[0] ?? '';
+            $url = $configModel::getCachedByPath('web/secure/base_url');
+
+            $sites[$store['code']] = [
+                'name' => $store['name'] ?? $store['code'],
+                'locale' => $locale,
+                'lang' => $lang,
+                'url' => $url,
+                'attributes' => [
+                    'magento_store_id' => $store['store_id'],
+                    'group' => $store['website_code'] ?? '',
+                    'disabled' => '{{ config:rapidez.statamic.sites.' . $store['code'] . '.attributes.disabled }}',
+                ]
+            ];
+        }
+
+        Site::setSites($sites);
+        Site::save();
+
+        return Command::SUCCESS;
+    }
+}
diff --git a/src/RapidezStatamicServiceProvider.php b/src/RapidezStatamicServiceProvider.php
index 12c92e6..50aa1b1 100644
--- a/src/RapidezStatamicServiceProvider.php
+++ b/src/RapidezStatamicServiceProvider.php
@@ -16,11 +16,12 @@
 use Statamic\Events\GlobalSetDeleted;
 use Illuminate\Support\ServiceProvider;
 use Illuminate\View\View as RenderedView;
-use Rapidez\Statamic\Commands\ImportBrands;
+use Rapidez\Statamic\Commands\CreateSites;
 use Rapidez\Statamic\Commands\InstallCommand;
-use Rapidez\Statamic\Forms\JsDrivers\Vue;
+use Rapidez\Statamic\Commands\ImportBrands;
 use Rapidez\Statamic\Commands\ImportProducts;
 use Rapidez\Statamic\Commands\ImportCategories;
+use Rapidez\Statamic\Forms\JsDrivers\Vue;
 use Rapidez\Statamic\Extend\SitesLinkedToMagentoStores;
 use Rapidez\Statamic\Http\Controllers\ImportsController;
 use Rapidez\Statamic\Http\Controllers\StatamicRewriteController;
@@ -41,7 +42,6 @@ public function boot()
         $this
             ->bootCommands()
             ->bootConfig()
-            ->bootSites()
             ->bootRoutes()
             ->bootViews()
             ->bootListeners()
@@ -55,37 +55,13 @@ public function boot()
         Alternates::register();
     }
 
-    public function bootSites() : self
-    {
-        $sites = [];
-        $stores = Rapidez::getStores();
-
-        foreach ($stores as $store) {
-            $sites[$store['code']] = [
-                'name' => $store['name'] ?? $store['code'],
-                'locale' => '{{ config:rapidez.statamic.sites.' . $store['code'] . '.locale }}',
-                'lang' => '{{ config:rapidez.statamic.sites.' . $store['code'] . '.lang }}',
-                'url' => '{{ config:rapidez.statamic.sites.' . $store['code'] . '.url }}',
-                'attributes' => [
-                    'magento_store_id' => $store['store_id'],
-                    'group' => $store['website_code'] ?? '',
-                    'disabled' => '{{ config:rapidez.statamic.sites.' . $store['code'] . '.attributes.disabled }}',
-                ]
-            ];
-        }
-
-        Site::setSites($sites);
-        Site::save();
-
-        return $this;
-    }
-
     public function bootCommands() : self
     {
         $this->commands([
             ImportCategories::class,
             ImportProducts::class,
             ImportBrands::class,
+            CreateSites::class,
             InstallCommand::class,
         ]);
 

From d6c0c553e8bddcf44c787ad5e64ee4a91872cb25 Mon Sep 17 00:00:00 2001
From: Kevin Meijer <kevin@justbetter.nl>
Date: Fri, 18 Oct 2024 14:11:00 +0200
Subject: [PATCH 05/14] Automatically register and cache sites

---
 src/Commands/CreateSites.php              | 46 -----------------------
 src/Extend/SitesLinkedToMagentoStores.php | 36 ++++++++++++++++++
 src/RapidezStatamicServiceProvider.php    |  2 -
 3 files changed, 36 insertions(+), 48 deletions(-)
 delete mode 100644 src/Commands/CreateSites.php

diff --git a/src/Commands/CreateSites.php b/src/Commands/CreateSites.php
deleted file mode 100644
index 87d4e0b..0000000
--- a/src/Commands/CreateSites.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-
-namespace Rapidez\Statamic\Commands;
-
-use Statamic\Facades\Site;
-use Illuminate\Console\Command;
-use Rapidez\Core\Facades\Rapidez;
-
-class CreateSites extends Command
-{
-    protected $signature = 'rapidez:statamic:create:sites';
-
-    protected $description = 'Create sites based on the active Magento stores.';
-
-    public function handle(): int
-    {
-        $sites = [];
-        $stores = Rapidez::getStores();
-        $configModel = config('rapidez.models.config');
-
-        foreach ($stores as $store) {
-            Rapidez::setStore($store['store_id']);
-
-            $locale = $configModel::getCachedByPath('general/locale/code');
-            $lang = explode('_', $locale)[0] ?? '';
-            $url = $configModel::getCachedByPath('web/secure/base_url');
-
-            $sites[$store['code']] = [
-                'name' => $store['name'] ?? $store['code'],
-                'locale' => $locale,
-                'lang' => $lang,
-                'url' => $url,
-                'attributes' => [
-                    'magento_store_id' => $store['store_id'],
-                    'group' => $store['website_code'] ?? '',
-                    'disabled' => '{{ config:rapidez.statamic.sites.' . $store['code'] . '.attributes.disabled }}',
-                ]
-            ];
-        }
-
-        Site::setSites($sites);
-        Site::save();
-
-        return Command::SUCCESS;
-    }
-}
diff --git a/src/Extend/SitesLinkedToMagentoStores.php b/src/Extend/SitesLinkedToMagentoStores.php
index cef143c..6900a64 100644
--- a/src/Extend/SitesLinkedToMagentoStores.php
+++ b/src/Extend/SitesLinkedToMagentoStores.php
@@ -2,6 +2,8 @@
 
 namespace Rapidez\Statamic\Extend;
 
+use Illuminate\Support\Facades\Cache;
+use Rapidez\Core\Facades\Rapidez;
 use Statamic\Sites\Sites;
 
 class SitesLinkedToMagentoStores extends Sites
@@ -20,4 +22,38 @@ public function findByMageRunCode($code)
     {
         return collect($this->sites)->get($code);
     }
+
+    protected function getSavedSites()
+    {
+        return Cache::driver('array')->rememberForever('statamic_sites', function () {
+            $sites = [];
+            $stores = Rapidez::getStores();
+            $configModel = config('rapidez.models.config');
+
+            foreach ($stores as $store) {
+                if (config('rapidez.statamic.sites.' . $store['code'] . '.attributes.disabled')) {
+                    continue;
+                }
+
+                Rapidez::setStore($store['store_id']);
+
+                $locale = $configModel::getCachedByPath('general/locale/code');
+                $lang = explode('_', $locale)[0] ?? '';
+                $url = $configModel::getCachedByPath('web/secure/base_url');
+
+                $sites[$store['code']] = [
+                    'name' => $store['name'] ?? $store['code'],
+                    'locale' => $locale,
+                    'lang' => $lang,
+                    'url' => $url,
+                    'attributes' => [
+                        'magento_store_id' => $store['store_id'],
+                        'group' => $store['website_code'] ?? ''
+                    ]
+                ];
+            }
+
+            return $sites ?: $this->getFallbackConfig();
+        });
+    }
 }
diff --git a/src/RapidezStatamicServiceProvider.php b/src/RapidezStatamicServiceProvider.php
index 50aa1b1..7b60dd6 100644
--- a/src/RapidezStatamicServiceProvider.php
+++ b/src/RapidezStatamicServiceProvider.php
@@ -16,7 +16,6 @@
 use Statamic\Events\GlobalSetDeleted;
 use Illuminate\Support\ServiceProvider;
 use Illuminate\View\View as RenderedView;
-use Rapidez\Statamic\Commands\CreateSites;
 use Rapidez\Statamic\Commands\InstallCommand;
 use Rapidez\Statamic\Commands\ImportBrands;
 use Rapidez\Statamic\Commands\ImportProducts;
@@ -61,7 +60,6 @@ public function bootCommands() : self
             ImportCategories::class,
             ImportProducts::class,
             ImportBrands::class,
-            CreateSites::class,
             InstallCommand::class,
         ]);
 

From 3dd1e480d5a51a22fe95347914318d91026090fa Mon Sep 17 00:00:00 2001
From: Kevin Meijer <kevin@justbetter.nl>
Date: Fri, 18 Oct 2024 14:19:41 +0200
Subject: [PATCH 06/14] Updated readme

---
 README.md | 32 +++-----------------------------
 1 file changed, 3 insertions(+), 29 deletions(-)

diff --git a/README.md b/README.md
index e11977d..3d2a111 100644
--- a/README.md
+++ b/README.md
@@ -94,36 +94,10 @@ And if you'd like to change the views:
 php artisan vendor:publish --provider="Rapidez\Statamic\RapidezStatamicServiceProvider" --tag=views
 ```
 
+### Sites configuration
 
-### Magento Store ID
-
-It is important to add the Magento store ID for every site in the attributes section within `resources/sites.yaml` and use the store code as key. Because the url can vary per enviroment(local, testing, staging, production) we use the "sites" section of the config file and reference that in the `sites.yaml`. The current site will be determined based on the `MAGE_RUN_CODE`. By default Statamic uses the url for this; that's still the fallback. If you need to generate some urls with a multisite it's a best practice to specify the `url` per site from env variables. See the [Statamic multisite docs](https://statamic.dev/multi-site#url). Optionally you could set the `group` within the `attributes` if you'd like to group sites to filter the alternate hreflang link tags. You could also set the `disabled` within the `attributes` section to true if you want to exclude this site from being altered with Statamic data.
-```yaml
-'default' => [
-    'name' => env('APP_NAME', 'Statamic'),
-    'locale' => 'en_EN',
-    'lang' => 'en_EN',
-    'url' => '/',
-    'attributes' => [
-        'magento_store_id' => 1,
-        'group' => 'default',
-        'disabled' => false,
-    ],
-],
-```
-
-
-```yaml
-default:
-  name: '{{ config:rapidez.statamic.sites.default.name }}'
-  locale: '{{ config:rapidez.statamic.sites.default.locale }}'
-  lang: '{{ config:rapidez.statamic.sites.default.lang }}'
-  url: '{{ config:rapidez.statamic.sites.default.url }}'
-  attributes:
-    magento_store_id: '{{ config:rapidez.statamic.sites.default.attributes.magento_store_id }}'
-    group: '{{ config:rapidez.statamic.sites.default.attributes.group }}'
-    disabled: '{{ config:rapidez.statamic.sites.default.attributes.disabled }}'
-```
+There is no need for a sites.yaml in your project anymore.
+The sites will be registered automatically based on the configured stores in Magento.
 
 ### Showing content on categories and products
 

From fb94b6c70f2c505f6ae99e1d345382f7a3343ec8 Mon Sep 17 00:00:00 2001
From: Kevin Meijer <kev10@live.nl>
Date: Tue, 22 Oct 2024 13:14:26 +0200
Subject: [PATCH 07/14] Update README.md

Co-authored-by: Roy Duineveld <royduineveld@gmail.com>
---
 README.md | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 3d2a111..23a1735 100644
--- a/README.md
+++ b/README.md
@@ -96,8 +96,7 @@ php artisan vendor:publish --provider="Rapidez\Statamic\RapidezStatamicServicePr
 
 ### Sites configuration
 
-There is no need for a sites.yaml in your project anymore.
-The sites will be registered automatically based on the configured stores in Magento.
+There is no need for a `sites.yaml` in your project anymore. The sites will be registered automatically based on the configured stores in Magento.
 
 ### Showing content on categories and products
 

From 410a72303369f8696581c395e06dcd82a8760004 Mon Sep 17 00:00:00 2001
From: Kevin Meijer <kevin@justbetter.nl>
Date: Tue, 22 Oct 2024 13:56:23 +0200
Subject: [PATCH 08/14] Updated readme

---
 README.md | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/README.md b/README.md
index 3d2a111..929ae02 100644
--- a/README.md
+++ b/README.md
@@ -99,6 +99,16 @@ php artisan vendor:publish --provider="Rapidez\Statamic\RapidezStatamicServicePr
 There is no need for a sites.yaml in your project anymore.
 The sites will be registered automatically based on the configured stores in Magento.
 
+The current site will be determined based on the `MAGE_RUN_CODE`. By default Statamic uses the url for this; that's still the fallback. The `group` within the `attributes` will be set based on the `website_code` from Magento. This makes it possible to add alternate hreflang link tags.
+You could also set the `disabled` within the `attributes` section in the `rapidez/statamic.php` config to true if you want to exclude this site from being altered with Statamic data.
+```yaml
+'default' => [
+    'attributes' => [
+        'disabled' => false,
+    ],
+],
+```
+
 ### Showing content on categories and products
 
 By default you'll get the configured content on categories and products available withint the `$content` variable. This can be enabled/disabled with the `fetch` configurations within the `rapidez/statamic.php` config file. If you want to display the configured content from the default page builder you can include this in your view:

From e1a1bd2fae2331e5c84722c2e3d56d139edb811d Mon Sep 17 00:00:00 2001
From: Kevin Meijer <kevin@justbetter.nl>
Date: Tue, 22 Oct 2024 14:02:17 +0200
Subject: [PATCH 09/14] Added user model description to readme

---
 README.md | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 929ae02..1269a25 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,9 @@ composer require rapidez/statamic
 ## Install command
 
 The install command will help you set up all the necessary settings.
-It will mainly setup the [Eloquent driver](https://github.com/statamic/eloquent-driver) and publish the necessary vendor from the rapidez/statamic repo. 
+It will mainly setup the [Eloquent driver](https://github.com/statamic/eloquent-driver) and publish the necessary vendor from the rapidez/statamic repo.
+
+Before running the install script, make sure you have an existing User model as Statamic requires this. See: [Statamic docs](https://statamic.dev/tips/storing-users-in-a-database)
 
 ```
 php artisan rapidez-statamic:install

From 1b3dad2a24a586065fe133203c50a2980e31495d Mon Sep 17 00:00:00 2001
From: Kevin Meijer <kevin@justbetter.nl>
Date: Tue, 22 Oct 2024 14:03:26 +0200
Subject: [PATCH 10/14] Cache by default driver

---
 src/Extend/SitesLinkedToMagentoStores.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Extend/SitesLinkedToMagentoStores.php b/src/Extend/SitesLinkedToMagentoStores.php
index 6900a64..58eab3f 100644
--- a/src/Extend/SitesLinkedToMagentoStores.php
+++ b/src/Extend/SitesLinkedToMagentoStores.php
@@ -25,7 +25,7 @@ public function findByMageRunCode($code)
 
     protected function getSavedSites()
     {
-        return Cache::driver('array')->rememberForever('statamic_sites', function () {
+        return Cache::rememberForever('statamic_sites', function () {
             $sites = [];
             $stores = Rapidez::getStores();
             $configModel = config('rapidez.models.config');

From 41d6db0496f83f8d5787db54a1594b73fee8b00e Mon Sep 17 00:00:00 2001
From: Kevin Meijer <kevin@justbetter.nl>
Date: Tue, 22 Oct 2024 14:08:11 +0200
Subject: [PATCH 11/14] Up minimum required Statamic version

---
 composer.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/composer.json b/composer.json
index 9734382..1348f27 100644
--- a/composer.json
+++ b/composer.json
@@ -35,7 +35,7 @@
         "rapidez/blade-directives": "^0.6",
         "justbetter/statamic-glide-directive": "^2.1",
         "statamic-rad-pack/runway": "^7.6",
-        "statamic/cms": "^5.0",
+        "statamic/cms": "^5.29",
         "statamic/eloquent-driver": "^4.9",
         "tormjens/eventy": "^0.8"
     },

From 99f103a3e5bd6d04434b518a8aa60bf3ec1e8309 Mon Sep 17 00:00:00 2001
From: Kevin Meijer <kevin@justbetter.nl>
Date: Tue, 22 Oct 2024 14:18:07 +0200
Subject: [PATCH 12/14] Cleaned up code

---
 src/RapidezStatamicServiceProvider.php | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/RapidezStatamicServiceProvider.php b/src/RapidezStatamicServiceProvider.php
index 7b60dd6..2a350c1 100644
--- a/src/RapidezStatamicServiceProvider.php
+++ b/src/RapidezStatamicServiceProvider.php
@@ -31,9 +31,7 @@ class RapidezStatamicServiceProvider extends ServiceProvider
 {
     public function register()
     {
-        $this->app->extend(Sites::class, function () {
-            return new SitesLinkedToMagentoStores();
-        });
+        $this->app->extend(Sites::class, fn () => new SitesLinkedToMagentoStores());
     }
 
     public function boot()

From aff469043fcf89092ebc6618983dd8e737966988 Mon Sep 17 00:00:00 2001
From: Kevin Meijer <kevin@justbetter.nl>
Date: Tue, 29 Oct 2024 15:57:41 +0100
Subject: [PATCH 13/14] Updated config

---
 README.md | 185 +++---------------------------------------------------
 1 file changed, 9 insertions(+), 176 deletions(-)

diff --git a/README.md b/README.md
index d0454ef..c59ad5a 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,7 @@ This package helps you integrate Statamic within your Rapidez project by adding
 
 - Products, categories and brands are integrated through [Runway](https://github.com/duncanmcclean/runway) as read only resources so you can link them to the content
 - Products, categories, brands and pages collections as starting point so you can extend this however you'd like
+- Site registration based on the active Magento stores
 - Route merging so Statamic routes work as fallback
 - Page builder fieldset with a product slider, content, image and form component
 - Responsive images with Glide through [justbetter/statamic-glide-directive](https://github.com/justbetter/statamic-glide-directive)
@@ -15,6 +16,13 @@ This package helps you integrate Statamic within your Rapidez project by adding
 
 You need to have `statamic/cms` installed in your Rapidez installation. Follow the [installation guide](https://statamic.dev/installing/laravel).
 
+Make sure you have an existing User model as Statamic requires this.
+If you don't have a User model you can get it from the [Laravel repo](https://github.com/laravel/laravel/blob/11.x/app/Models/User.php).
+
+You will also need the migrations for the users table, this can be found [here](https://github.com/laravel/laravel/blob/11.x/database/migrations/0001_01_01_000000_create_users_table.php).
+At last you need to make some changes to your User model to make it compatible with Statamic, 
+make sure to follow [this guide](https://statamic.dev/tips/storing-users-in-a-database#in-an-existing-laravel-app) after requiring `rapidez/statamic` in your project.
+
 ## Installation
 
 ```
@@ -26,8 +34,6 @@ composer require rapidez/statamic
 The install command will help you set up all the necessary settings.
 It will mainly setup the [Eloquent driver](https://github.com/statamic/eloquent-driver) and publish the necessary vendor from the rapidez/statamic repo.
 
-Before running the install script, make sure you have an existing User model as Statamic requires this. See: [Statamic docs](https://statamic.dev/tips/storing-users-in-a-database)
-
 ```
 php artisan rapidez-statamic:install
 ```
@@ -46,180 +52,7 @@ We recommend migrating the following options to the database when setting up the
 - Terms
 - Tokens
 
-After you're done running the install command make sure to check the guide below for some manual changes.
-
-## Configuration
-
-Have a look within the `rapidez/statamic.php` config file, if you need to change something you can publish it with:
-
-```
-php artisan vendor:publish --provider="Rapidez\Statamic\RapidezStatamicServiceProvider" --tag=config
-```
-
-### Assets disk
-
-Make sure there is an assets disk within `config/filesystems.php`
-```
-'disks' => [
-    'assets' => [
-        'driver' => 'local',
-        'root' => public_path('assets'),
-        'url' => '/assets',
-        'visibility' => 'public',
-    ],
-],
-```
-
-### Routing
-
-As Rapidez uses route fallbacks to allow routes to be added with lower priority than Magento routes, this package is used to fix this, as statamic routes on itself will overwrite your Magento routes. Make sure default Statamic routing is disabled in `config/statamic/routes.php`. We'll register the Statamic routes from this packages after the Magento routes.
-
-```php
-'enabled' => false,
-```
-
-#### Homepage
-
-If you'd like to use the homepage from Statamic instead of the CMS page from Magento; just disable the homepage in Magento.
-
-### Publish Collections, Blueprints and Fieldsets
-
-If you have run the install command these will already have been published.
-
-```
-php artisan vendor:publish --provider="Rapidez\Statamic\RapidezStatamicServiceProvider" --tag=rapidez-statamic-content
-```
-
-And if you'd like to change the views:
-
-```
-php artisan vendor:publish --provider="Rapidez\Statamic\RapidezStatamicServiceProvider" --tag=views
-```
-
-### Sites configuration
-
-There is no need for a `sites.yaml` in your project anymore. The sites will be registered automatically based on the configured stores in Magento.
-
-The current site will be determined based on the `MAGE_RUN_CODE`. By default Statamic uses the url for this; that's still the fallback. The `group` within the `attributes` will be set based on the `website_code` from Magento. This makes it possible to add alternate hreflang link tags.
-You could also set the `disabled` within the `attributes` section in the `rapidez/statamic.php` config to true if you want to exclude this site from being altered with Statamic data.
-```yaml
-'default' => [
-    'attributes' => [
-        'disabled' => false,
-    ],
-],
-```
-
-### Showing content on categories and products
-
-By default you'll get the configured content on categories and products available withint the `$content` variable. This can be enabled/disabled with the `fetch` configurations within the `rapidez/statamic.php` config file. If you want to display the configured content from the default page builder you can include this in your view:
-```
-@includeWhen(isset($content), 'rapidez-statamic::page_builder', ['content' => $content?->content])
-```
-- Product: `resources/views/vendor/rapidez/product/overview.blade.php`
-- Category: `resources/views/vendor/rapidez/category/overview.blade.php`
-
-
-### Brand overview and single brand
-#### Brand pages
-Single brand pages display a listing page with your products linked to that brand. By default the single brand pages are disabled. You can enable routing for them in `content/collections/brands.yaml` by adding a route for them:
-
-```yaml
-    route: '/brands/{slug}'
-```
-#### Brand overview
-If you want an overview page for your brands you can add a `Brand overview` component on a normal page. This will automaticly load a view with your brands grouped by their first letter.
-
-### Importing categories or products from Magento
-
-#### Categories
-
-To make it easier to change category content in bulk you can create category entries with content copied over in bulk.
-
-To do this run one of the following:
-
-```bash
-# Most basic, import all categories in all sites
-php artisan rapidez:statamic:import:categories --all
-
-# Import all categories in the site with handle "default" only
-php artisan rapidez:statamic:import:categories --all --site=default
-
-# import select categories in multiple sites
-php artisan rapidez:statamic:import:categories 5 8 9 category-url-key --site=default --site=another_site
-```
-
-By default the slug and title of the category are copied.
-
-If you have a custom blueprint and would like to add more data from the category you can do so by hooking into the Eventy event: `rapidez-statamic:category-entry-data`
-
-```php
-Eventy::addFilter('rapidez.statamic.category.entry.data', fn($category) => [
-        'description' => $category->description,
-    ]
-);
-```
-
-#### Products
-
-To make it easier to change product content in bulk you can create product entries with content copied over in bulk.
-
-To do this run one of the following:
-
-```bash
-# Most basic, import all products in all sites
-php artisan rapidez:statamic:import:products
-
-# Import all products in the site with handle "default" only
-php artisan rapidez:statamic:import:products --site=default
-```
-
-By default the slug and title of the product are copied.
-
-If you have a custom blueprint and would like to add more data from the product you can do so by hooking into the Eventy event: `rapidez.statamic.product.entry.data`
-
-```php
-Eventy::addFilter('rapidez.statamic.product.entry.data', fn($product) => [
-        'description' => $product->description,
-    ]
-);
-```
-
-#### Brands
-
-To make it easier to change brands content in bulk you can create brand entries with content copied over in bulk.
-
-To do this run one of the following:
-
-```bash
-# Import all brands in all sites
-php artisan rapidez:statamic:import:brands
-
-# Import all brands in the site with handle "default" only
-php artisan rapidez:statamic:import:brands --site=default
-```
-
-By default the slug and title of the brand are copied.
-
-If you have a custom blueprint and would like to add more data from the brand you can do so by hooking into the Eventy event `rapidez.statamic.brand.entry.data`
-
-```php
-Eventy::addFilter('rapidez.statamic.brand.entry.data', fn($brand) => [
-        'description' => $brand->description,
-    ]
-);
-```
-
-
-### Globals
-
-Globals will be available through the `$globals` variable.
-For example; If you created a global with the handle `header` and added a field called `logo` in this global it will be available as `$globals->header->logo`.
-
-
-### Forms
-
-When you create a form you could use `rapidez-statamic::emails.form` as HTML template which uses the [Laravel mail template](https://laravel.com/docs/master/mail#customizing-the-components) with all fields in a table, make sure you enable markdown!
+After you're done running the install command make sure to check our configuration guide written [here](https://docs.rapidez.io/3.x/packages/statamic.html).
 
 ### Upgrading
 

From 71ded965baee004eeb2d36d2629c07f79b6f49fe Mon Sep 17 00:00:00 2001
From: Kevin Meijer <kevin@justbetter.nl>
Date: Tue, 5 Nov 2024 14:53:02 +0100
Subject: [PATCH 14/14] Changed config for disabled sites

---
 config/rapidez/statamic.php               | 13 +++----------
 src/Extend/SitesLinkedToMagentoStores.php |  2 +-
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/config/rapidez/statamic.php b/config/rapidez/statamic.php
index 33eabdf..8c4adc5 100644
--- a/config/rapidez/statamic.php
+++ b/config/rapidez/statamic.php
@@ -78,14 +78,7 @@
         ],
     ],
 
-    'sites' => [
-        'default' => [
-            'locale' => 'en_EN',
-            'lang' => 'en_EN',
-            'url' => '/',
-            'attributes' => [
-                'disabled' => false,
-            ],
-        ],
-    ]
+    'disabled_sites' => [
+        // '{site_handle}'
+    ],
 ];
diff --git a/src/Extend/SitesLinkedToMagentoStores.php b/src/Extend/SitesLinkedToMagentoStores.php
index 947e6bc..3a6d5fa 100644
--- a/src/Extend/SitesLinkedToMagentoStores.php
+++ b/src/Extend/SitesLinkedToMagentoStores.php
@@ -35,7 +35,7 @@ protected function getSavedSites()
             $configModel = config('rapidez.models.config');
 
             foreach ($stores as $store) {
-                if (config('rapidez.statamic.sites.' . $store['code'] . '.attributes.disabled')) {
+                if (in_array($store['code'], config('rapidez.statamic.disabled_sites'))) {
                     continue;
                 }