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

[Bug]: Theme input settings do not allow types "metaobject" or "metaobject_list" #4414

Open
2 tasks done
wallfly opened this issue Sep 5, 2024 · 2 comments
Open
2 tasks done
Labels
Area: @shopify/theme @shopify/theme package issues Type: Bug Something isn't working

Comments

@wallfly
Copy link

wallfly commented Sep 5, 2024

Please confirm that you have:

  • Searched existing issues to see if your issue is a duplicate. (If you’ve found a duplicate issue, feel free to add additional information in a comment on it.)
  • Reproduced the issue in the latest CLI version.

In which of these areas are you experiencing a problem?

Theme

Expected behavior

I should be able to add the input setting type of "metaobject" or "metaobject_list" and the Theme / Schema validator in theme dev would validate it and allow the theme to properly render the input settings in the Theme editor.

Actual behavior

When I add the input setting in my section liquid file using type "metaobject" or "metaobject_list", theme dev cannot validate my input setting type and prints:

Invalid schema: setting with id="faq_metaobject_list" type is invalid

Verbose output

DEBUG Refreshing preview _shopify_essential cookie
DEBUG Proxying HEAD https://mystore.myshopify.com/?preview_theme_id=139015553201&_fd=0&pb=0
DEBUG `-> 302 request_id: 6d62c030-fc60-412a-bca2-c9933404e43e-1725505530
DEBUG Proxying GET https://mystore.myshopify.com/pages/lp/chiropractic-offices?_ab=0&_fd=0&_sc=1&pb=0&preview_theme_id=139015553201&_fd=0&pb=0
DEBUG `-> 302 request_id: 9298587f-762c-4b64-abb0-bd910798222f-1725505531
DEBUG Proxying GET https://mystore.myshopify.com/pages/lp/chiropractic-offices?_ab=0&_fd=0&_sc=1&pb=0&_fd=0&pb=0
DEBUG `-> 200 request_id: 92c1bd99-23e4-46a6-8e50-0834118e50c6-1725505531
DEBUG Renew _shopify_essential cookie by the response
DEBUG Proxying GET https://mystore.myshopify.com/checkouts/internal/preloads.js?locale=en-US&_fd=0&pb=0
DEBUG [HotReload] Connected to SSE stream
DEBUG `-> 200 request_id:
DEBUG Proxying GET https://mystore.myshopify.com/cart.js?r=2.50096004167&_fd=0&pb=0
DEBUG `-> 200 request_id: fce4a8c1-6357-4c29-b79f-67076d84dc01-1725505534
DEBUG Proxying GET https://mystore.myshopify.com/pages/lp/chiropractic-offices?_ab=0&_fd=0&_sc=1&pb=0&_fd=0&pb=0
DEBUG `-> 200 request_id: c12aee9a-5636-4252-bee1-7b52148a69e7-1725505680
DEBUG Renew _shopify_essential cookie by the response
DEBUG Proxying GET https://mystore.myshopify.com/checkouts/internal/preloads.js?locale=en-US&_fd=0&pb=0
DEBUG [HotReload] Connected to SSE stream
DEBUG `-> 200 request_id:
DEBUG Proxying GET https://mystore.myshopify.com/cart.js?r=2.50093676816&_fd=0&pb=0
DEBUG `-> 200 request_id: 6835b03c-fc14-4fa2-af68-0f1ebcbf178f-1725505681
DEBUG [HotReload] Modified sections/collapsible-faqs.liquid
DEBUG update sections/collapsible-faqs.liquid
DEBUG Proxying POST https://mystore.myshopify.com/pages/lp/chiropractic-offices?_ab=0&_fd=0&_sc=1&pb=0&_fd=0&pb=0
DEBUG PUT https://mystore.myshopify.com/admin/api/unstable/themes/139015553201/assets.json with request_id: d5d0a91a-5cde-4a5d-8e8d-6bd721e08b52-1725505701
  • 20:08:22 ERROR  » update sections/collapsible-faqs.liquid:
  Invalid schema: setting with id="faq_metaobject_list" type is invalid
DEBUG `-> 200 request_id: 5f7fe91d-5f33-4436-adad-3d164de82b7f-1725505701
DEBUG Renew _shopify_essential cookie by the response
DEBUG Proxying GET https://mystore.myshopify.com/checkouts/internal/preloads.js?locale=en-US&_fd=0&pb=0
DEBUG [HotReload] Connected to SSE stream
DEBUG Proxying POST https://mystore.myshopify.com/cart.js?r=2.50094045164&_fd=0&pb=0
DEBUG `-> 200 request_id:
DEBUG `-> 200 request_id: abcf042d-6edc-46cb-a073-f5e3c1e6527c-1725505703

Reproduction steps

I have been getting into the metaobject definitions and creating themes for these, so I can template pages and easily populate them in a set of inputs rather than coding up new files each time. Great! I was excited as it fit a need.

Created my metaobjects and then a template for them. Each template and liquid section would then bind it's input values to the values in the metaobject entry.

I have created a sales_landing_page metaobject with 2 dozen fields in it. I also have a faqs metaobject with 2 fields in it (question and answer). Each landing page does not need the same FAQs, but the most relevant ones.

This means I needed a 1:many cardinal relationship in my 2 "database tables", wanting many FAQs on one Landing Page entry.
So I created a new field on sales_landing_page as a metaobject reference, referencing the faqs metaobject.

Where I get blocked is creating a theme input setting allowing me to bind an input setting to the faq metaobject reference field on my sales_landing_page.

Except I was not sure what input setting type to use. The Shopify docs do not show any reference to metaobject or metaobject_list input setting types. HOWEVER, VScode intellisense shows me these two types, so went forward with it.

At first I just put metaobject_list but then the schema validator told me that metaobject_type was required. But I could not find ANY documentation on this either.

Intellisense provides me this link to refer to the metaobject_list input setting type, but this page makes no reference.
https://shopify.dev/docs/themes/architecture/settings/input-settings#metaobject_list

  1. Run shopify theme dev on an existing working theme and load your local env pages that you will work on
  2. In a code editor, open an existing or new liquid section file, add a new input setting with "type": "metaobject" or "type": "metaobject_list" ... Here is mine:
  "settings": [
   ...,
    {
      "type": "metaobject_list",
      "metaobject_type": "faqs",
      "id": "faq_metaobject_list",
      "label": "FAQs metaobject reference"
    },
    ...
   ]
  1. Save the file to allow for hot reloading
  2. See the output in the theme dev terminal where it will show:
    Invalid schema: setting with id="faq_metaobject_list" type is invalid

Operating System

Mac OS Sonoma 14.6.1

Shopify CLI version (check your project's package.json if you're not sure)

Shopify CLI; v=3.66.1

Shell

zsh

Node version (run node -v if you're not sure)

No response

What language and version are you using in your application?

No response

@wallfly wallfly added the Type: Bug Something isn't working label Sep 5, 2024
@lucyxiang lucyxiang added the Area: @shopify/theme @shopify/theme package issues label Sep 6, 2024
@wallfly
Copy link
Author

wallfly commented Sep 10, 2024

Maybe this can help? https://shopify.dev/docs/storefronts/themes/architecture/settings/dynamic-sources#referencing-metaobject-fields

Thanks @etienne-ditchlabs -- I have tried this as well, but could not get it to do what I needed, given the limitations of Liquid.

Here is a similar scenario to the FAQs, but with different data.

  • I have an citations metaobject, which contains a topics_list that tells me what the citation is about (ie, 'sleep','cardiovascular','anxiety')
  • and a sales_landing_page metaobject that has a field for relevant_citation_topics - here I want to choose which citations to show, so I will have another list of topics (ie, 'sleep','stress')
  • Then I want to be able to do a contains check to match and filter for citations that match my sales_landing_page.relevant_citation_topics
  • But this has proven quite difficult, perhaps not possible. The contains check does not ever yield TRUE even when the strings match exactly
  • This ALSO has the distinct disadvantage of having to pull ALL citations and then filter after, instead of being able to query using a where filter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: @shopify/theme @shopify/theme package issues Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants