Skip to content

Commit f1ae296

Browse files
authored
Allow sales channel to be determined by a config value (#309)
1 parent eefda3c commit f1ae296

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

config/shopify.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,10 @@
131131
* In which collection should the Shopify products be created
132132
*/
133133
'collection_handle' => env('SHOPIFY_COLLECTION_HANDLE', 'products'),
134+
135+
/**
136+
* What Sales Channel in Shopify should be used to determine the product availablity
137+
* (ensure this matches exactly)
138+
*/
139+
'sales_channel' => env('SHOPIFY_SALES_CHANNEL', 'Online Store'),
134140
];

docs/content/en/CMS/importing-data.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ Fetch a single product by their ID. You can find the ID from the `product_id` va
4848
php artisan shopify:import:single ID_HERE
4949
```
5050

51+
## Published state
52+
53+
By default the `published` state and `published_at` of the product is determined by the values of `Online Store` sales channel. If you want to use a different sales channel to determine availability you can specify the name of the channel in the `SHOPIFY_SALES_CHANNEL` env variable, e.g. `SHOPIFY_SALES_CHANNEL="My other channel"`.
54+
5155
## Metafields
5256

5357
Any product and variant meta fields will be automatically added to the Statamic entry data, with the same handle as their key in Shopify and using the raw value.
@@ -85,4 +89,4 @@ $html = (new StatamicRadPack\Shopify\Support\RichTextConverter)->convert($metafi
8589
$bard = (new StatamicRadPack\Shopify\Support\RichTextConverter)->convert($metafield['value'], true);
8690

8791

88-
```
92+
```

docs/content/en/env.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ These allow you to tweak how the system works. Please check out the `config/shop
3838
| Value | Description |
3939
| -------------------|-------------------------------------------------------------------------------------------------|
4040
| `SHOPIFY_JOB_QUEUE` | The queue to run the shopify jobs on. Allows you to set it to a different one than the default. |
41-
| `SHOPIFY_COLLECTION_HANDLE` | The handle of the collection that contains your Shopify products, defaults to 'products'. |
41+
| `SHOPIFY_COLLECTION_HANDLE` | The handle of the collection that contains your Shopify products, defaults to 'products'. |
42+
| `SHOPIFY_SALES_CHANNEL` | The Sales Channel to use for product availability, defaults to 'Online Store'. |

src/Jobs/ImportSingleProductJob.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ public function handle()
285285
// publication state
286286
try {
287287
$publicationStatus = collect(Arr::get($this->data, 'resourcePublications.edges', []))
288-
->where('node.publication.name', 'Online Store')
288+
->where('node.publication.name', config('shopify.sales_channel', 'Online Store'))
289289
->map(function ($channel) {
290290
if (! $node = $channel['node'] ?? []) {
291291
return [];

0 commit comments

Comments
 (0)