craftcms / shopify

Synchronize and extend product data from your Shopify storefront.
MIT License
44 stars 25 forks source link

Issue with Craft headlessMode config #68

Closed QuentinLeclercq closed 1 year ago

QuentinLeclercq commented 1 year ago

Description

Using Craft with headlessMode creates error when saving Shopify plugin settings.

Error

PHP Warning – [yii\base\ErrorException](https://www.yiiframework.com/doc-2.0/yii-base-errorexception.html)
Undefined array key "template"
Capture d’écran 2023-05-25 à 10 45 11

Steps to reproduce

  1. In config/general.php, set headless mode to true
  2. Go to Shopify plugin settings, hit the Save button
  3. Error appears

Additional info

lukeholder commented 1 year ago

Looking at that error, it's coming from the old version of the plugin in your composer.json installed into your vendor directory called "shopify-product-fetcher".

Make sure you have the correct package in your composer.json

composer require craftcms/shopify -w

and remove the old one and do a

composer update

QuentinLeclercq commented 1 year ago

Hey @lukeholder, thanks for your quick answer!

Still experiencing the same issue after removing nmaier95/shopify-product-fetcher and adding/installing craftcms/shopify.

I'm not sure to understand how it can works here: https://github.com/craftcms/shopify/blob/develop/src/controllers/SettingsController.php#L67

The template key isn't sent when we enable headless mode, which is normal I guess. See the routing content in the POST request. We only have uriFormat.

image

So the Undefined array key "template" error looks like to be relevant. If I add a check on the template key like in the image below, saving works:

image

Thanks for you help!

andrevvm commented 1 year ago

Hi @lukeholder, I'm having the same issue as Quentin here. Even after changing the config to headlessMode(false) and reinstalling Shopify app.

Temporarily bypassing with Quentin's solution above...

curtishenson commented 1 year ago

Yeah this is a legitimate bug, looks like there is already a pull request to fix this as well #57

lukeholder commented 1 year ago

Thanks everyone. I'll get a fix out shortly.

lukeholder commented 1 year ago

This is now out in 3.2.0!

See the notes in the upgrading section of the README