From 1670d5ecfc874e5107995eddb59a7a9e0b7c2a7a Mon Sep 17 00:00:00 2001 From: Bob Date: Thu, 8 Aug 2024 13:45:29 +0200 Subject: [PATCH] Config and runway blueprints --- README.md | 30 +++++++++++---- config/rapidez/statamic.php | 47 +++++++---------------- resources/blueprints/runway/brand.yaml | 31 +++++++++++++++ resources/blueprints/runway/category.yaml | 17 ++++++++ resources/blueprints/runway/product.yaml | 23 +++++++++++ src/RapidezStatamicServiceProvider.php | 1 + 6 files changed, 108 insertions(+), 41 deletions(-) create mode 100644 resources/blueprints/runway/brand.yaml create mode 100644 resources/blueprints/runway/category.yaml create mode 100644 resources/blueprints/runway/product.yaml diff --git a/README.md b/README.md index 523ab82..fa2a754 100644 --- a/README.md +++ b/README.md @@ -97,18 +97,32 @@ php artisan vendor:publish --provider="Rapidez\Statamic\RapidezStatamicServicePr ### 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. 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. +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:app:name }}' - url: / - locale: nl_NL + 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: 1 - group: 'default' - disabled: false - + 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 }}' ``` ### Showing content on categories and products diff --git a/config/rapidez/statamic.php b/config/rapidez/statamic.php index 1b32c03..0ff694b 100644 --- a/config/rapidez/statamic.php +++ b/config/rapidez/statamic.php @@ -59,17 +59,6 @@ 'read_only' => true, 'title_field' => 'name', 'cp_icon' => 'table', - 'blueprint' => [ - 'sections' => [ - 'main' => [ - 'fields' => [ - ['handle' => 'entity_id', 'field' => ['type' => 'integer']], - ['handle' => 'sku', 'field' => ['type' => 'text']], - ['handle' => 'name', 'field' => ['type' => 'text']], - ] - ] - ] - ] ], \Rapidez\Statamic\Models\Category::class => [ @@ -77,16 +66,6 @@ 'read_only' => true, 'title_field' => 'name', 'cp_icon' => 'array', - 'blueprint' => [ - 'sections' => [ - 'main' => [ - 'fields' => [ - ['handle' => 'entity_id', 'field' => ['type' => 'integer']], - ['handle' => 'name', 'field' => ['type' => 'text']], - ] - ] - ] - ] ], \Rapidez\Statamic\Models\Brand::class => [ @@ -95,19 +74,21 @@ 'title_field' => 'value_store', 'cp_icon' => 'tags', 'order_by' => 'sort_order', - 'blueprint' => [ - 'sections' => [ - 'main' => [ - 'fields' => [ - ['handle' => 'option_id', 'field' => ['type' => 'integer']], - ['handle' => 'sort_order', 'field' => ['type' => 'integer']], - ['handle' => 'value_admin', 'field' => ['type' => 'text']], - ['handle' => 'value_store', 'field' => ['type' => 'text']], - ] - ] - ] - ], ], ], ], + + '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/resources/blueprints/runway/brand.yaml b/resources/blueprints/runway/brand.yaml new file mode 100644 index 0000000..4348142 --- /dev/null +++ b/resources/blueprints/runway/brand.yaml @@ -0,0 +1,31 @@ +tabs: + main: + display: Main + sections: + - + fields: + - + handle: option_id + field: + type: integer + localizable: false + visibility: read_only + - + handle: sort_order + field: + type: integer + localizable: false + visibility: read_only + - + handle: value_admin + field: + type: text + localizable: false + visibility: read_only + - + handle: value_store + field: + type: text + localizable: false + visibility: read_only +title: Brand diff --git a/resources/blueprints/runway/category.yaml b/resources/blueprints/runway/category.yaml new file mode 100644 index 0000000..eb76fee --- /dev/null +++ b/resources/blueprints/runway/category.yaml @@ -0,0 +1,17 @@ +tabs: + main: + sections: + - + fields: + - + handle: entity_id + field: + type: integer + localizable: false + visibility: read_only + - + handle: name + field: + type: text + localizable: false + visibility: read_only diff --git a/resources/blueprints/runway/product.yaml b/resources/blueprints/runway/product.yaml new file mode 100644 index 0000000..9be5997 --- /dev/null +++ b/resources/blueprints/runway/product.yaml @@ -0,0 +1,23 @@ +tabs: + main: + sections: + - + fields: + - + handle: entity_id + field: + type: integer + localizable: false + visibility: read_only + - + handle: sku + field: + type: text + localizable: false + visibility: read_only + - + handle: name + field: + type: text + localizable: false + visibility: read_only diff --git a/src/RapidezStatamicServiceProvider.php b/src/RapidezStatamicServiceProvider.php index dd4b094..be77fcb 100644 --- a/src/RapidezStatamicServiceProvider.php +++ b/src/RapidezStatamicServiceProvider.php @@ -170,6 +170,7 @@ public function bootPublishables() : self __DIR__.'/../resources/content/collections' => base_path('content/collections'), __DIR__.'/../resources/content/assets' => base_path('content/assets'), __DIR__.'/../resources/fieldsets' => resource_path('fieldsets'), + __DIR__.'/../resources/blueprints/runway' => resource_path('blueprints/vendor/runway'), ], 'rapidez-statamic-content'); $this->publishes([