1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Stockbase\Integration\Model\Config; |
4
|
|
|
|
5
|
|
|
use Magento\Framework\App\Config\ScopeConfigInterface; |
6
|
|
|
use Magento\Framework\App\Config\Storage\WriterInterface; |
7
|
|
|
use Stockbase\Integration\Model\Config\Source\Environment; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Stockbase main mobule configuration resource wrapper. |
11
|
|
|
*/ |
12
|
|
|
class StockbaseConfiguration |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
const CONFIG_MODULE_ENABLED = 'stockbase/integration/module_enabled'; |
16
|
|
|
const CONFIG_ENVIRONMENT = 'stockbase/integration/environment'; |
17
|
|
|
const CONFIG_USERNAME = 'stockbase/integration/username'; |
18
|
|
|
const CONFIG_PASSWORD = 'stockbase/integration/password'; |
19
|
|
|
const CONFIG_EAN_FIELD = 'stockbase/integration/ean_field'; |
20
|
|
|
const CONFIG_ORDER_PREFIX = 'stockbase/integration/order_prefix'; |
21
|
|
|
const CONFIG_IMAGES_SYNC = 'stockbase/integration/images_sync_enabled'; |
22
|
|
|
const CONFIG_IMAGES_CRON_SYNC = 'stockbase/integration/images_sync_cron_enabled'; |
23
|
|
|
const CONFIG_IMAGES_FILTER_PRODUCTS = 'stockbase/integration/images_filter_products'; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var ScopeConfigInterface |
27
|
|
|
*/ |
28
|
|
|
private $scopeConfig; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* StockbaseConfiguration constructor. |
32
|
|
|
* @param ScopeConfigInterface $scopeConfig |
33
|
|
|
*/ |
34
|
2 |
|
public function __construct(ScopeConfigInterface $scopeConfig) |
35
|
|
|
{ |
36
|
2 |
|
$this->scopeConfig = $scopeConfig; |
37
|
2 |
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @return bool |
41
|
|
|
*/ |
42
|
2 |
|
public function isModuleEnabled() |
43
|
|
|
{ |
44
|
2 |
|
return (bool) $this->scopeConfig->getValue(self::CONFIG_MODULE_ENABLED); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Gets Stockbase environment name. |
49
|
|
|
* |
50
|
|
|
* @return string |
51
|
|
|
*/ |
52
|
2 |
|
public function getEnvironment() |
53
|
|
|
{ |
54
|
2 |
|
return $this->scopeConfig->getValue(self::CONFIG_ENVIRONMENT) ?: Environment::STAGING; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return string |
59
|
|
|
*/ |
60
|
2 |
|
public function getUsername() |
61
|
|
|
{ |
62
|
2 |
|
return $this->scopeConfig->getValue(self::CONFIG_USERNAME); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return string |
67
|
|
|
*/ |
68
|
2 |
|
public function getPassword() |
69
|
|
|
{ |
70
|
2 |
|
return $this->scopeConfig->getValue(self::CONFIG_PASSWORD); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
2 |
|
public function getEanFieldName() |
77
|
|
|
{ |
78
|
2 |
|
return $this->scopeConfig->getValue(self::CONFIG_EAN_FIELD); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return string |
83
|
|
|
*/ |
84
|
2 |
|
public function getOrderPrefix() |
85
|
|
|
{ |
86
|
2 |
|
return $this->scopeConfig->getValue(self::CONFIG_ORDER_PREFIX); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return bool |
91
|
|
|
*/ |
92
|
|
|
public function isImagesSyncEnabled() |
93
|
|
|
{ |
94
|
|
|
return (bool) $this->scopeConfig->getValue(self::CONFIG_IMAGES_SYNC); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return bool |
99
|
|
|
*/ |
100
|
|
|
public function isImagesSyncCronEnabled() |
101
|
|
|
{ |
102
|
|
|
return (bool) $this->scopeConfig->getValue(self::CONFIG_IMAGES_CRON_SYNC); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @return bool |
107
|
|
|
*/ |
108
|
|
|
public function filterProcessedProducts() |
109
|
|
|
{ |
110
|
|
|
return (bool) $this->scopeConfig->getValue(self::CONFIG_IMAGES_FILTER_PRODUCTS); |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|