Skip to content

Get multisite product collection import working#294

Merged
ryanmitchell merged 4 commits intostatamic-rad-pack:mainfrom
daun:fix/multisite-collection-import
Jul 13, 2025
Merged

Get multisite product collection import working#294
ryanmitchell merged 4 commits intostatamic-rad-pack:mainfrom
daun:fix/multisite-collection-import

Conversation

@daun
Copy link
Contributor

@daun daun commented Jul 12, 2025

Importing product collections into a multisite setup is currently failing for a number of reasons.

This is an attempt to solve this by:

Use the short collection id instead of the full id

Previously, the collection queried was duplicated, so gid://shopify/Collection/123445gid://shopify/Collection/12345. This should just be gid://shopify/Collection/12345

Use the lang of the site as query param

Previously, the whole locale was used (en_US), which Shopify doesn't return translations for. Short en seems to work.

Here's an example query from the docs on the translatableResource endpoint:

query {
    translatableResource(resourceId: "gid://shopify/Collection/1007901140") {
      resourceId
      translations(locale: "fr") {
        key
        value
      }
    }
  }

Adjust data path

The correct path through the response seems to be data.translatableResource.translations, not translatableResource.translatableContent. This one might also be due to API schema changes on the Storefront end of things. Happy to add a conditional to keep backwards compatibility.

Here's an example response from the docs on the translatableResource endpoint:

{
  "translatableResource": {
    "resourceId": "gid://shopify/Collection/1007901140",
    "translations": [
      {
        "key": "title",
        "value": "la collection"
      }
    ]
  }
}

Assume a LocalizedTerm

For some reason, the term would always already be a LocalizedTerm instance, which doesn't have a dataForLocale method. Switching to $term->in($local) seems to work better.

@daun
Copy link
Contributor Author

daun commented Jul 12, 2025

Tests seem to be failing because the mock API response data is out of date.

@ryanmitchell
Copy link
Contributor

It would have been the response for the version of the api it was targeting - 2024-07 I think. If they have changed it the addon will need to support both, as you suggested.

@daun

This comment was marked as outdated.

@daun
Copy link
Contributor Author

daun commented Jul 12, 2025

Just found a PR from a year ago making the exact change from translatableContent to translations on the product side. No issues so far. Shouldn't we just switch the collections over to the same format as well, instead of adding a conditional? The products don't have a conditional and seem to be working okay.

@ryanmitchell
Copy link
Contributor

Yeah looks like I missed it.

Thanks for this and the other PRs - appreciate the work you've done on them!

@ryanmitchell ryanmitchell merged commit 1203cdb into statamic-rad-pack:main Jul 13, 2025
4 checks passed
@daun
Copy link
Contributor Author

daun commented Jul 13, 2025

Thanks for the quick merge and short feedback loop!

@daun daun deleted the fix/multisite-collection-import branch August 2, 2025 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants