|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Helix\Shopify\Collection; |
|
4
|
|
|
|
|
5
|
|
|
use Helix\Shopify\Base\AbstractEntity; |
|
6
|
|
|
use Helix\Shopify\Base\AbstractEntity\CrudTrait; |
|
7
|
|
|
use Helix\Shopify\Base\AbstractEntity\MetafieldTrait; |
|
8
|
|
|
use Helix\Shopify\CustomCollection; |
|
9
|
|
|
use Helix\Shopify\Product; |
|
10
|
|
|
use Helix\Shopify\SmartCollection; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Abstract for collections. |
|
14
|
|
|
* |
|
15
|
|
|
* @see CustomCollection |
|
16
|
|
|
* @see SmartCollection |
|
17
|
|
|
* |
|
18
|
|
|
* @method string getBodyHtml () |
|
19
|
|
|
* @method string getHandle () |
|
20
|
|
|
* @method null|Image getImage () |
|
21
|
|
|
* @method null|string getPublishedAt () |
|
22
|
|
|
* @method string getPublishedScope () `web|global`, read-only for custom collections. |
|
23
|
|
|
* @method string getSortOrder () See the sort constants. |
|
24
|
|
|
* @method string getTemplateSuffix () |
|
25
|
|
|
* @method string getTitle () |
|
26
|
|
|
* @method string getUpdatedAt () |
|
27
|
|
|
* |
|
28
|
|
|
* @method $this setBodyHtml (string $html) |
|
29
|
|
|
* @method $this setHandle (string $handle) |
|
30
|
|
|
* @method $this setImage (?Image $image) |
|
31
|
|
|
* @method $this setSortOrder (string $order) See the sort constants. |
|
32
|
|
|
* @method $this setTemplateSuffix (string $suffix) |
|
33
|
|
|
* @method $this setTitle (string $title) |
|
34
|
|
|
*/ |
|
35
|
|
|
abstract class AbstractCollection extends AbstractEntity |
|
36
|
|
|
{ |
|
37
|
|
|
|
|
38
|
|
|
use CrudTrait; |
|
39
|
|
|
use MetafieldTrait; |
|
40
|
|
|
|
|
41
|
|
|
const SCOPE_WEB = 'web'; |
|
42
|
|
|
const SCOPE_GLOBAL = 'global'; |
|
43
|
|
|
|
|
44
|
|
|
const SORT_ALPHA_ASC = 'alpha-asc'; |
|
45
|
|
|
const SORT_ALPHA_DESC = 'alpha-desc'; // shopify docs have a typo. it's desc. |
|
46
|
|
|
const SORT_BEST_SELLING = 'best-selling'; |
|
47
|
|
|
const SORT_CREATED = 'created'; |
|
48
|
|
|
const SORT_CREATED_DESC = 'created-desc'; |
|
49
|
|
|
const SORT_MANUAL = 'manual'; |
|
50
|
|
|
const SORT_PRICE_ASC = 'price-asc'; |
|
51
|
|
|
const SORT_PRICE_DESC = 'price-desc'; |
|
52
|
|
|
|
|
53
|
|
|
const MAP = [ |
|
54
|
|
|
'image' => Image::class, |
|
55
|
|
|
]; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @param Product $product |
|
59
|
|
|
* @return AbstractCollect |
|
60
|
|
|
*/ |
|
61
|
|
|
abstract public function newCollect(Product $product); |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @return Product[] |
|
65
|
|
|
*/ |
|
66
|
|
|
public function getProducts() |
|
67
|
|
|
{ |
|
68
|
|
|
return Product::loadAll($this, "collections/{$this->getId()}/products"); |
|
69
|
|
|
} |
|
70
|
|
|
} |