Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config and runway blueprints #68

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
47 changes: 14 additions & 33 deletions config/rapidez/statamic.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,34 +59,13 @@
'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 => [
'name' => 'Categories',
'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 => [
Expand All @@ -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,
],
],
]
];
31 changes: 31 additions & 0 deletions resources/blueprints/runway/brand.yaml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions resources/blueprints/runway/category.yaml
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions resources/blueprints/runway/product.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions src/RapidezStatamicServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down