Open sunscreem opened 2 weeks ago
Is this a future dated product?
Hey @ryanmitchell I don't think we use dates at all on this project - but let me check.
Hey @ryanmitchell Double checked and no dates are used. I can email you over a quick video to show the issue if you would like?
On fresh installs your collection should be dated and publish dates are considered. I’m wondering if the line below needs to be GTE not GT :
@ryanmitchell Thanks - I've tried disabling dates on the product collections and still seeing the same issue. Note that the published status in the control panel also shows the incorrect status until I clear the stache.
If you just resave the product rather than clearing the stache does it resolve it?
Thanks Ryan. If I save from the control panel it will overwrite the data on the product so here's how I saved it in tinker. You will see I clear the stache and everything is working as expected:
Weird.
If you dd or log here https://github.com/statamic-rad-pack/shopify/blob/695be9f1267b32a498ee3f1509ddf2328758e9a8/src/Jobs/ImportSingleProductJob.php#L227 what status is being set? I wonder if we also need to set $entry->set('published', $published)
but I didnt think that was needed.
@ryanmitchell After a bunch of experimenting it does seem that with the STATAMIC_STACHE_WATCHER
set to false
that data changes on the products trigger an update to the stache, but the published status change doesn't. I'm not sure why.
To work around it I've tried adding:
Stache::store('entries::products')->clear();
Stache::store('entries::products')->warm();
Just here and that seems to work.
What are your thoughts on using that as a workaround? I'm tempted to raise this as a bug on the Statamic repo as I can't find any discussion of it anywhere and which is odd.
That shouldn’t be necessary. Saving the item should be enough. Did you try setting published in the data like I suggested?
I did yes - it didn't change anything - sorry I should have said earlier.
The whole thing seems odd - definitely not something we're seeing on our installs. Are you running a queue?
No locally in testing no. I can try to recreate on a clean install that that helps?
You could listen for the ProductCreate/Delete/Update events and call the stache:clear in there.
Yeah - that's a plan. Tempted to try to recreate on a clean install anyway. Can you leave this open for now, I'll do that tomorrow if I get chance?
Hey @ryanmitchell I'm finally getting the bottom of this.
Would you mind explaining what this code is doing?
It’s syncs the publication status and dates from shopifys online store channel
Cool thanks. Does that work with the publish status set in the $data array above?
I'm finding if I put a quickly addin $entry->published(true)
- or $entry->published(false)
just before the $entry-save()
on 238 it fixing my stache issue.
If you have an ‘online store’ channel in shopify - make sure you have the product available on it.
Thanks Ryan. I'll do a little more digging.
Description
We've noticed that although most product changes at Shopify, such as a name or description change, are updated via the webhooks almost instantly, this doesn't appear to be the case for the published status.
Is this a Statamic issue?
Steps to reproduce
Environment
Environment Application Name: X Laravel Version: 11.30.0 PHP Version: 8.2.25 Composer Version: 2.3.2 Environment: production Debug Mode: OFF URL: X Maintenance Mode: OFF Timezone: Europe/London Locale: en_GB
Cache Config: CACHED Events: CACHED Routes: CACHED Views: CACHED
Drivers Broadcasting: log Cache: file Database: mysql Logs: stack / single, bugsnag Mail: smtp Queue: redis Session: file
Statamic Addons: 7 Sites: 1 Stache Watcher: Disabled Static Caching: half Version: 5.36.0 PRO
Statamic Addons statamic-rad-pack/shopify: 4.0.6