1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Helix\Shopify\Product; |
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\Product; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* A product image. |
12
|
|
|
* |
13
|
|
|
* @see https://shopify.dev/docs/admin-api/rest/reference/products/product-image |
14
|
|
|
* |
15
|
|
|
* @method $this setAttachment (string $base64) @depends create-only |
16
|
|
|
* @method $this setFilename (string $filename) @depends create-only |
17
|
|
|
* @method $this setSrc (string $url) @depends create-only |
18
|
|
|
* |
19
|
|
|
* @method string getCreatedAt () read-only |
20
|
|
|
* @method string getFilename () |
21
|
|
|
* @method int getHeight () |
22
|
|
|
* @method int getPosition () |
23
|
|
|
* @method string getProductId () injected, read-only |
24
|
|
|
* @method string getUpdatedAt () read-only |
25
|
|
|
* @method string[] getVariantIds () |
26
|
|
|
* @method int getWidth () |
27
|
|
|
* |
28
|
|
|
* @method bool hasVariantIds () |
29
|
|
|
* |
30
|
|
|
* @method $this setHeight (int $height) |
31
|
|
|
* @method $this setPosition (int $position) |
32
|
|
|
* @method $this setVariantIds (string[] $ids) |
33
|
|
|
* @method $this setWidth (int $width) |
34
|
|
|
*/ |
35
|
|
|
class Image extends AbstractEntity |
36
|
|
|
{ |
37
|
|
|
|
38
|
|
|
use CrudTrait; |
39
|
|
|
use MetafieldTrait; |
40
|
|
|
|
41
|
|
|
const TYPE = 'image'; |
42
|
|
|
const DIR = 'images'; |
43
|
|
|
|
44
|
|
|
protected function _container() |
45
|
|
|
{ |
46
|
|
|
return $this->getProduct(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
final protected function _metafieldType(): string |
50
|
|
|
{ |
51
|
|
|
return 'product_image'; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function getProduct() |
55
|
|
|
{ |
56
|
|
|
return Product::load($this, $this->getProductId()); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
} |