Skip to content
Open
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
3 changes: 3 additions & 0 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- Removed the Feed Me integration for Shopify Products fields.
- Shopify doesn’t require `craftcms/yii2-adapter`.
- Webhook subscriptions with an `index.php?p=` URL no longer reach Craft, and need to be re-created. See UPGRADE.md.
- Products synced before the upgrade need `php artisan craft:resave:shopify-products --update-search-index` to make their option values searchable. See UPGRADE.md.
- The product edit screen now shows the Shopify details in the sidebar’s metadata.
- Syncing products from Shopify no longer creates a revision of each product.
- Fixed a bug where garbage collection never deleted products that had been removed from Shopify.
Expand All @@ -28,6 +29,8 @@
- Fixed a bug where products that were draft or archived in Shopify showed as Live.
- Fixed a bug where the “Shopify Status” condition rule didn’t match products correctly.
- Fixed a bug where the `shopifyStatus` product query param was case-sensitive on PostgreSQL.
- Fixed a bug where the product index couldn’t be sorted by title or Shopify status.
- Fixed a bug where products’ option values weren’t searchable.

### Extensibility

Expand Down
88 changes: 14 additions & 74 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,83 +209,23 @@ Discover orphaned subscriptions using the [`webhookSubscriptions()`](https://sho

## Upgrading

> While it is technically possible to upgrade directly from 6.x to the latest 8.x version, we strongly recommend reviewing the [6.x upgrade guide](#from-6x), as an intermediate step.
### From Shopify 8

### From 7.x
Shopify 9 requires Craft CMS 6 and PHP 8.5, so you upgrade it together with Craft. [UPGRADE.md](UPGRADE.md) lists the upgrade steps, and every breaking change with its replacement. In short:

> [!WARNING]
> Ensure the Craft queue is empty, before upgrading.
> Any pending [sync](#synchronization) jobs will be unable to update their status after the migration runs.
> In-progress bulk-synchronization operations (in Shopify) should be unaffected, unless you opt in to [additional features](#additional-features) during the upgrade.

Shopify 8.0 requires **Craft CMS 5.10.7 or later**, and drops support for Craft 4.x.

The most significant change for most developers will be our handling of Shopify IDs and GIDs.
`craft\shopify\models\Variant::$shopifyId` now holds only the **numeric** Shopify ID (e.g. `”123456789”`).
The full GID (e.g. `”gid://shopify/ProductVariant/123456789”`) is available via the new `$shopifyGid` property.
**Update any templates or custom code that compared or used `$variant->shopifyId` as a GID string.**

Examples in this document reflect this change; you should no longer need to to manipulate the GID string for add-to-cart forms or other situations that required the numeric ID.

> [!WARNING]
> This also changes the plugin’s GraphQL API: querying a variant’s `shopifyId` field previously returned the full GID, and now returns the numeric ID only.
> Use the `shopifyGid` field if you need the full GID.
> If you have external clients or headless front-ends querying this plugin’s GraphQL API, audit them for this change.

The following methods are deprecated in favor of GID-based equivalents. Update any direct calls:
1. Update to Shopify 8.2.1 or later on Craft 5, and let the queue finish.
2. Follow [Upgrading to Craft 6.x](https://craftcms.com/docs/6.x/upgrade.html), and require `craftcms/shopify:^9.0` at the same time as Craft 6.
3. Run `php artisan craft:up`.
4. Re-create your webhooks in each environment, and run a full sync.

- `craft\shopify\services\BulkOperations::getBulkOperationByShopifyId()` → `getBulkOperationByShopifyGid()`
- `craft\shopify\services\Products::deleteProductByShopifyId()` → `deleteProductByShopifyGid()`
- `craft\shopify\services\Products::deleteShopifyDataByShopifyId()` → `deleteShopifyDataByShopifyGid()`
- `craft\shopify\services\Products::syncProductByShopifyId()` → `syncProductByShopifyGid()`

> [!WARNING]
> The `shopify/shopify-api` package is no longer a dependency of this plugin. If any custom code references its classes directly—like `Shopify\Clients\Graphql`, `Shopify\Exception\ShopifyException`, `Shopify\Webhooks\Registry`, `Shopify\Auth\OAuth`, or `Shopify\Context`—update it to use the plugin’s own equivalents (`craft\shopify\clients\GraphqlClient`, `craft\shopify\exceptions\ShopifyApiException`, `craft\shopify\webhooks\WebhookRegistry`, `craft\shopify\auth\OAuthFlow`) instead.

If you plan to enable any of the new [Additional Features](#additional-features) or the `customScopes` setting as part of this upgrade, see the scope re-authorization requirements described there—enabling them after the app is already authorized requires updating your Shopify app’s scopes and re-authorizing.
Code that uses the plugin’s PHP classes, events or console commands needs updating. Templates that use `craft.shopifyProducts()`, product properties and the product query params keep working.

> [!TIP]
> The [changelog](https://github.com/craftcms/shopify/blob/8.x/CHANGELOG.md) contains a full list of added, changed, and deprecated classes and methods.

### From 6.x
> The [changelog](CHANGELOG.md) lists every added, changed and removed class and method.

> These instructions were originally published with the release of 7.x, but we have adapted them here for convenience.
> You only need to follow these instructions if you are upgrading from 6.x directly to 8.x.
### From Shopify 7 or earlier

Version 7.0 was primarily concerned with Shopify API compatibility, but the [new authentication mechanism](#connect-to-shopify) means that you’ll need to re-establish the connection to Shopify using the authentication scheme [described above](#connect-to-shopify).

Due to significant shifts in Shopify’s developer ecosystem, many of the [front-end cart management](#front-end-sdks) techniques we have recommended (like the _JS Buy SDK_ and _Buy Button JS_) are no longer viable.

> [!TIP]
> We strongly recommend reviewing this same section on the [6.x](https://github.com/craftcms/shopify/blob/6.x/README.md#upgrading) branch, as there were a number of breaking changes and deprecations during the upgrade from 5.x.
> The [changelog](https://github.com/craftcms/shopify/blob/7.x/CHANGELOG.md) contains specific information about the classes and methods that have been added, removed, or deprecated.

After the upgrade, you **must** [delete and re-create webhooks](#set-up-webhooks) for each environment.
Webhooks are registered and delivered with a specific version, and a mismatch will result in errors.

Your “legacy custom app” can be left as-is or deleted, once all your environments have been migrated to the Dev Dashboard connection.
While this plugin has no need for those credentials, confirm with the store owner that no other external services depend on them!

#### Credentials

At the beginning of 2026, Shopify overhauled how “apps” are created, moving them to the new [Dev Dashboard](https://shopify.dev/docs/apps/build/dev-dashboard).

You should be able to [create a new app](#create-an-app), and [install it](#install-in-a-store) using the new OAuth mechanism, without disruption to product synchronization.

#### Publishing and Status

Shopify has eliminated [sales channels for custom apps](https://shopify.dev/docs/apps/build/sales-channels/start-building), and therefore the [`publishedOnCurrentPublication` field](https://shopify.dev/docs/api/admin-graphql/2026-01/objects/Product#field-Product.fields.publishedOnCurrentChannel) is no longer available in Product queries.

This means that there is no official way to “publish” products to the Craft integration, but we cover some alternatives in the [sales channel emulation](#emulate-sales-channels) section.

#### Product Field Layouts

The product element editor has received a major overhaul. You can now choose exactly where Shopify data is placed, within the [field layout](#custom-fields).

#### Front-End SDKs

Shopify has retired many of its pre-built client-side frameworks, in favor of directly communicating with the generic [Storefront GraphQL API](#storefront-api-client).
You will need to revise how you query and mutate data, if your front-end currently depends on the JS Buy SDK or Buy Button JS.
Upgrade to Shopify 8 on Craft 5 first, following the [Shopify 8 upgrade instructions](https://github.com/craftcms/shopify/blob/8.x/README.md#upgrading). Then upgrade to Shopify 9.

## Product Element

Expand Down Expand Up @@ -334,7 +274,7 @@ In addition to the standard [element](https://craftcms.com/docs/5.x/system/eleme
| `updatedAt` | When the product was last updated in your Shopify store. (This will almost always be different from the element’s native `dateUpdated` property.) | `DateTime` |

All of these properties are available when working with a product element [in your templates](#templating).
Yii and Twig also allow you to access some values via magic getters—any [method](#methods) beginning with `get` (like `product.getDefaultVariant()`) can also be treated like a property (`product.defaultVariant`).
Twig also lets you access some values via magic getters—any [method](#methods) beginning with `get` (like `product.getDefaultVariant()`) can also be treated like a property (`product.defaultVariant`).

> [!IMPORTANT]
> See the Shopify documentation on the [product resource](https://shopify.dev/docs/api/admin-graphql/2026-01/objects/Product) for more information about what kinds of values to expect from these properties.
Expand Down Expand Up @@ -1008,7 +948,7 @@ Your customers can add products to their cart directly from your Craft site by `
For fully custom front-end solutions, consider the [Storefront API Javascript client](https://github.com/Shopify/shopify-app-js/tree/main/packages/api-clients/storefront-api-client), which is built and maintained with the new GraphQL API in mind.

```twig
{% do view.registerJsFile('https://unpkg.com/@shopify/storefront-api-client@1.0.5/dist/umd/storefront-api-client.min.js') %}
{% js 'https://unpkg.com/@shopify/storefront-api-client@1.0.5/dist/umd/storefront-api-client.min.js' %}

<script>
// Note that these values are interpolated into the script tag with Twig!
Expand Down Expand Up @@ -1463,10 +1403,10 @@ Errors from the API are printed to `stdout`.

### Element API

Your synchronized products can be published into an [Element API](https://plugins.craftcms.com/element-api) endpoint, just like any other element type. This allows you to set up a local JSON feed of products, decorated with any content you’ve added in Craft:
Your synchronized products can be published into an [Element API](https://plugins.craftcms.com/element-api) endpoint, just like any other element type. This allows you to set up a local JSON feed of products, decorated with any content you’ve added in Craft. Endpoints go in `config/craft/element-api.php`:

```php
use craft\shopify\elements\Product;
use CraftCms\Shopify\Product\Elements\Product;

return [
'endpoints' => [
Expand Down
49 changes: 40 additions & 9 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ This guide lists what changed in Shopify 9.0 and what you need to update in your

## Requirements

- Craft CMS 6.0 or later
- Craft CMS 6.0.0-beta.3 or later
- PHP 8.5 or later

Shopify 9 doesn't need `craftcms/yii2-adapter`. `craft6-revamp` adds the adapter to your project for your own templates and modules, and you can remove it once nothing else needs it.

## Upgrade steps

1. Update Shopify to 8.2.1 or later on Craft 5, and run its migrations.
2. Make sure the Craft queue is empty, so no Shopify sync jobs are pending.
3. Upgrade Craft and Shopify together, following [Upgrading to Craft 6.x](https://craftcms.com/docs/6.x/upgrade.html). Shopify 8 requires Craft 5 and Shopify 9 requires Craft 6, so change both constraints in your project's `composer.json` before you run `composer update`: set `craftcms/shopify` to `^9.0` at the same point you set `craftcms/cms` to Craft 6. The `craft6-revamp` tool doesn't change plugin constraints for you.
4. Run `php artisan craft:up`.
5. Move `config/shopify.php` to `config/craft/shopify.php`, if you have one.
4. If you have a `config/shopify.php` file, update it before you run `composer update` (see [Config file](#config-file)). `craft6-revamp` moves it to `config/craft/shopify.php`; move it yourself if you upgrade by hand.
5. Run `php artisan craft:up`.
6. If Shopify kept its access token in the database rather than in your `.env` file, re-authorize the app (see [Access token](#access-token)).
7. Re-create webhooks that Shopify sends to an `index.php?p=` URL, in each environment (see [Webhook URLs](#webhook-urls)).
8. Update cron jobs and deploy scripts that run Shopify console commands (see below).
9. Review the breaking changes below and update your code.
8. Run `php artisan craft:resave:shopify-products --update-search-index`, so searching products matches their option values (see [Search](#search)).
9. Update cron jobs and deploy scripts that run Shopify console commands (see below).
10. Review the breaking changes below and update your code.

The OAuth callback URL (`{cpTrigger}/shopify/auth`) is unchanged, so your Shopify app configuration doesn't need updating.

Expand All @@ -38,9 +41,9 @@ See [Install in a Store](README.md#install-in-a-store) for the full flow. The ne

### Webhook URLs

Shopify 9 still handles webhooks at `actions/shopify/webhook/handle`, `{cpTrigger}/actions/shopify/webhook/handle` and `shopify/webhook/handle`. Craft 6 doesn't route `index.php?p=` URLs, though. A subscription whose URL looks like `https://example.com/index.php?p=admin/actions/shopify/webhook/handle` gets a 403 response, so Shopify's changes stop reaching Craft. Shopify 8 created URLs in that form on many sites.
Shopify 9 still handles webhooks at `actions/shopify/webhook/handle`, `{cpTrigger}/actions/shopify/webhook/handle` and `shopify/webhook/handle`. Craft 6 doesn't route `index.php?p=` URLs, though. A subscription whose URL looks like `https://example.com/index.php?p=admin/actions/shopify/webhook/handle` gets an error response instead of reaching Shopify's handler, so Shopify's changes stop reaching Craft. Shopify 8 created URLs in that form on many sites.

The Webhooks screen in the control panel only lists subscriptions whose URL matches the one Shopify 9 creates, such as `https://example.com/actions/shopify/webhook/handle`. After the upgrade, it shows the old subscriptions as missing. In each environment:
The Webhooks screen in the control panel only lists subscriptions whose URL matches the one Shopify 9 creates, such as `https://example.com/admin/actions/shopify/webhook/handle`. After the upgrade, it shows the old subscriptions as missing. In each environment:

1. Go to **Shopify** → **Webhooks** and click **Create all webhooks**, or **Create missing webhooks** if some are listed.
2. List your app's subscriptions, and find the ones whose `uri` contains `index.php?p=`:
Expand All @@ -57,7 +60,7 @@ The Webhooks screen in the control panel only lists subscriptions whose URL matc

Subscriptions belong to the app, not the environment, so the list includes every environment's subscriptions. Only delete the ones for the environment you're upgrading. Run a full sync from the **Shopify Sync** utility afterwards, to pick up changes Shopify sent while the webhooks failed.

If your project installs `craftcms/yii2-adapter` for another plugin, the adapter still routes `index.php?p=` URLs, and the old subscriptions keep working. Re-create them anyway, so they don't depend on the adapter.
While your project still requires `craftcms/yii2-adapter` (`craft6-revamp` adds it), the adapter routes `index.php?p=` URLs, and the old subscriptions keep working. Re-create them anyway, so they don't stop working when you remove the adapter.

### Console commands

Expand All @@ -73,7 +76,27 @@ Console commands are Artisan commands now. The old command names still work as a

### Config file

Move `config/shopify.php` to `config/craft/shopify.php`. Use `env()` instead of `craft\helpers\App::env()` to read environment variables in it.
Shopify's config file is `config/craft/shopify.php` now. `craft6-revamp` moves `config/shopify.php` there; move it yourself if you upgrade by hand.

Use `env()` instead of `craft\helpers\App::env()` to read environment variables in it. `craft\helpers\App` only exists while the Yii 2 adapter is installed, and Shopify 9 doesn't need the adapter. Without it, a config file that still uses the class stops every Artisan command, including the ones `composer update` runs, with `Class "craft\helpers\App" not found`.

Before:

```php
use craft\helpers\App;

return [
'template' => App::env('SHOPIFY_PRODUCT_TEMPLATE') ?: 'shop/_product',
];
```

After:

```php
return [
'template' => env('SHOPIFY_PRODUCT_TEMPLATE') ?: 'shop/_product',
];
```

### Plugin and settings classes

Expand Down Expand Up @@ -313,6 +336,14 @@ The product edit screen shows the Shopify details in the sidebar’s metadata, b

On MySQL and MariaDB, product attributes that Shopify sends as `null`, such as `templateSuffix` for most products, were the string `null`. They're `null` now, as on Postgres, so a migration updates the `shopify_data` columns. Queries and conditions that matched `'null'`, such as `templateSuffix('null')`, match nothing now; use `templateSuffix(':empty:')`. Product query params also behave the same on every database: `:empty:` matches `null` and empty strings, and `totalInventory(':empty:')` no longer matches products with an inventory of `0`.

### Search

Shopify 9 adds each product's option values, such as “Large”, to the search index, so `craft.shopifyProducts().search('*Large*')` finds products by option value. Shopify 8 indexed them as empty, and Craft only re-indexes an attribute when it changes, so products synced before the upgrade stay unsearchable by option value until you run:

```bash
php artisan craft:resave:shopify-products --update-search-index
```

### Queue job

The job that processes a sync's data is a Laravel job now, with a new name:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"require": {
"php": "^8.5",
"carnage/php-graphql-client": "^1.14",
"craftcms/cms": "6.x-dev",
"craftcms/cms": "^6.0.0-beta.3",
"guzzlehttp/guzzle": "^7.2"
},
"require-dev": {
Expand Down
Loading
Loading