Skip to content
Open
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
47 changes: 29 additions & 18 deletions src/5.x/packages/statamic.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@

The Rapidez with [Statamic](https://statamic.com/) integration! 🤝🚀

::: info Version 7
This documentation is for [`rapidez/statamic`](https://github.com/rapidez/statamic) version 7
::: info Version 8
This documentation is for [`rapidez/statamic`](https://github.com/rapidez/statamic) `^8.0`, which requires PHP 8.4 and [Statamic 6](https://statamic.dev/).
:::

[[toc]]

## Features

- Products, categories, and brands are integrated through [Runway](https://github.com/statamic-rad-pack/runway)
- Products, categories, and read-only product attributes (plus attribute options) are integrated through [Runway](https://github.com/statamic-rad-pack/runway)
- Brand landing pages use Statamic's **`brands` collection** (page builder and SEO), still tied to Magento brand options for listings and filters; the Runway brands resource is hidden in the control panel so you edit brands in one place
- Automatic site registration based on Magento stores
- Routing: Statamic routes are the fallback
- Page builder fieldset with multiple components:
Expand Down Expand Up @@ -97,9 +98,11 @@ Make sure there is an assets disk within `config/filesystems.php`

## Content migration

The `statamic-content-migration:migrate-cms-pages` command is available to migrate your Magento 2 CMS pages to Statamic pages since rapidez/statamic V8.
The `statamic-content-migration:migrate-cms-pages` command migrates your Magento 2 CMS pages into Statamic's `pages` collection.
You can use this command as inspiration to create your own content migrations, like blog pages, or FAQ pages.

Optionally limit which pages are migrated with `--identifiers` (comma-separated Magento identifiers) and `--identifier-type` (`whitelist` or `blacklist`, default `whitelist`).

The ConvertField action will transform html into the bard component with the fieldName you pass.
It will use the CleanHtml action to transform messy Magento templates with widgets, variables, nested cms blocks into plain html.

Expand All @@ -109,15 +112,17 @@ Don't like what your html turned into? You can add or remove cleaning steps in `

## Runway / Magento data

With [Runway](https://github.com/statamic-rad-pack/runway), you're able to display data from an Eloquent model within Statamic. We're using this to have all products, categories, and brands from Magento visible within Statamic, without the need of importing and syncing data. These Runway models can be used to link anything within Statamic to existing Magento data.
With [Runway](https://github.com/statamic-rad-pack/runway), you're able to display data from an Eloquent model within Statamic. We're using this to have products, categories, and product attribute data from Magento visible within Statamic, without the need of importing and syncing data. These Runway models can be used to link anything within Statamic to existing Magento data.

Brands still use a Runway model under the hood (for example in relations), but the brands Runway resource is **hidden** in the control panel. You add and edit brand landing content as entries in the **`brands` collection** instead, so editors are not faced with two separate brand UIs.

For example, the product slider component within the page builder has a relation with the products Runway model. This way, you can select from all Magento products you'd like to display within the slider.

You can also enrich data with this; when you want to use Statamic to add data on product, category, or brand pages. When saving an entry we're not touching the Magento tables, those are always read-only! We are observing the "updating" event on those models and save all data to a Statamic entry. When reveiving a model we're doing opposite; merging the data from Magento with the data from the Statamic entry so we just have one collection.
You can also enrich data with this; when you want to use Statamic to add data on product, category, or brand pages. When saving an entry we're not touching the Magento tables, those are always read-only! We are observing the "updating" event on those models and save all data to a Statamic entry. When retrieving a model we're doing the opposite; merging the data from Magento with the data from the Statamic entry so you still have a single merged view (for brands, that Statamic side is the `brands` collection entry linked to the Magento option).

### Displaying content

If you are going to enrich product / category pages with content from Statamic, you'll find all data within the `$content` variable.
If you are going to enrich product or category pages with content from Statamic, you'll find the page builder field on the merged entry in `$content->content`.

To display the default page builder content, you have to add this to your view:

Expand All @@ -128,13 +133,17 @@ To display the default page builder content, you have to add this to your view:
- Product: `resources/views/vendor/rapidez/product/overview.blade.php`
- Category: `resources/views/vendor/rapidez/category/overview.blade.php`

Brand landing pages use the same `rapidez-statamic::page_builder` partial, but the default blueprint exposes **two** page builder areas. The bundled brand view passes **`$content`** (top) and **`$bottom_content`** straight into the page builder include. Override `resources/views/vendor/rapidez-statamic/brands/show.blade.php` if you want a different layout around the listing.

::: details Disable `$content`
If you don't want `$content` on the product / category pages, you can disable it from the `config/rapidez/statamic.php` config file by setting the `fetch` option to `false`
If you don't want `$content` on the product or category pages, you can disable it from the `config/rapidez/statamic.php` config file by setting `fetch.product` or `fetch.category` to `false`
:::

## Brand pages

Just make sure the `brand_attribute_id` is correct within `config/rapidez/statamic.php` and all brands will be available within Statamic automatically. If you want to have actual brand pages on the frontend displaying all the products of that brand, you have to enable the route per store within `config/rapidez/statamic/builder.php`:
Just make sure the `brand_attribute_id` is correct within `config/rapidez/statamic.php` so Magento knows which attribute represents a brand. Brand landing content (page builder above and below the product listing, plus SEO fields) lives in the **`brands` collection** in the control panel; the Runway brands resource is configured with `hidden` so you manage brands there only.

If you want to have actual brand pages on the frontend displaying all the products of that brand, you have to enable the route per store within `config/rapidez/statamic/builder.php`:

```php
'routes' => [
Expand All @@ -159,13 +168,13 @@ To render a navigation somewhere we provide two options; a full main navigation

### Navigation helper

With Statamic you can get a data by tag in Blade with:
With Statamic you can get data by tag in Blade with:

```php
Statamic::tag('nav:footer')->fetch()
```

This will result in multiple queries to get all data. When you're linking to for example a category, each category will be a query resulting in a lot of queries. This packages provides a "helper" that fetches the navigation completely with all children and the result will be unified and cached. When a navigation changes; the cache will refreshed automatically.
This will result in multiple queries to get all data. When you're linking to for example a category, each category will be a query resulting in a lot of queries. This package provides a "helper" that fetches the navigation completely with all children and the result will be unified and cached. When a navigation changes; the cache will be refreshed automatically.

```php
RapidezStatamic::nav('nav:footer')
Expand Down Expand Up @@ -217,7 +226,7 @@ All Statamic globals will be available through the `$globals` variable within yo
When you create a form, you can use `rapidez-statamic::emails.form` as the HTML template, which uses the [Laravel mail template](https://laravel.com/docs/12.x/mail#customizing-the-components) with all fields in a table. Make sure you enable markdown!

## Images
When using Rapidez Statamic, the package pre-integrates the [Glide directive package](https://github.com/justbetter/statamic-glide-directive) to work seamlessly with your Statamic install. Just use the Glide directive as shown, and the package will handle image manipulation with the transformations dictated by your parameters.
When using Rapidez Statamic, the package pre-integrates the [Glide directive package](https://github.com/justbetter/statamic-glide-directive) to work seamlessly with your Statamic install. It also pushes the Glide head partial onto the `rapidez::layouts.app` stack so the directive can load correctly. Just use the Glide directive as shown, and the package will handle image manipulation with the transformations dictated by your parameters.

```blade
@responsive($image, [
Expand Down Expand Up @@ -255,7 +264,7 @@ As an example, the category pages:

## Static caching

Statamic comes with [static caching](https://statamic.dev/static-caching) and with this packages we're adding the middleware that handles that from Statamic to all Rapidez web routes. When you configure static caching with Statamic it will also be applied to all Rapidez routes!
Statamic comes with [static caching](https://statamic.dev/static-caching) and with this package we're adding the middleware that handles that from Statamic to all Rapidez web routes. When you configure static caching with Statamic it will also be applied to all Rapidez routes!

::: details I'm using multiple stores
When using Statamic Static caching in a multisite setup, you typically need to [manually configure](https://statamic.dev/static-caching#paths) a path for each site for the static files to be stored. However, with Rapidez Statamic, this manual step isn't necessary. The integration automatically sets the correct paths based on the store definitions in the Magento database, saving you time and reducing potential errors.
Expand Down Expand Up @@ -292,7 +301,7 @@ You should also set up exclusions for a few routes in your `config/statamic/stat
'class' => null,
'urls' => [
'/login',
'/register'
'/register',
'/checkout',
'/checkout/*',
],
Expand Down Expand Up @@ -349,13 +358,15 @@ return [

## Upgrading

### From 6.x to 7.x
### From 7.x to 8.x

:::: details
::: details

Just run:
Version 8 upgrades the integration to [Statamic 6](https://statamic.dev/) (and related dependencies such as Runway 9 and the Glide directive v4). Make sure your stack meets PHP 8.4, then run:

```bash
composer update rapidez/statamic -W
```
::::

Follow Statamic's own upgrade guide for any control panel or content changes required by Statamic 6.
:::