|
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
|
2 |
|
/** |
|
31
|
|
|
* @var WriterInterface |
|
32
|
2 |
|
*/ |
|
33
|
2 |
|
protected $configWriter; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* StockbaseConfiguration constructor. |
|
37
|
|
|
* @param ScopeConfigInterface $scopeConfig |
|
38
|
2 |
|
*/ |
|
39
|
|
|
public function __construct( |
|
40
|
2 |
|
ScopeConfigInterface $scopeConfig, |
|
41
|
|
|
WriterInterface $configWriter |
|
42
|
|
|
) { |
|
43
|
|
|
$this->scopeConfig = $scopeConfig; |
|
44
|
|
|
$this->configWriter = $configWriter; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
2 |
|
* @return bool |
|
49
|
|
|
*/ |
|
50
|
2 |
|
public function isModuleEnabled() |
|
51
|
|
|
{ |
|
52
|
|
|
return (bool) $this->scopeConfig->getValue(self::CONFIG_MODULE_ENABLED); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
2 |
|
* Gets Stockbase environment name. |
|
57
|
|
|
* |
|
58
|
2 |
|
* @return string |
|
59
|
|
|
*/ |
|
60
|
|
|
public function getEnvironment() |
|
61
|
|
|
{ |
|
62
|
|
|
return $this->scopeConfig->getValue(self::CONFIG_ENVIRONMENT) ?: Environment::STAGING; |
|
63
|
|
|
} |
|
64
|
2 |
|
|
|
65
|
|
|
/** |
|
66
|
2 |
|
* @return string |
|
67
|
|
|
*/ |
|
68
|
|
|
public function getUsername() |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->scopeConfig->getValue(self::CONFIG_USERNAME); |
|
71
|
|
|
} |
|
72
|
2 |
|
|
|
73
|
|
|
/** |
|
74
|
2 |
|
* @return string |
|
75
|
|
|
*/ |
|
76
|
|
|
public function getPassword() |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->scopeConfig->getValue(self::CONFIG_PASSWORD); |
|
79
|
|
|
} |
|
80
|
2 |
|
|
|
81
|
|
|
/** |
|
82
|
2 |
|
* @return string |
|
83
|
|
|
*/ |
|
84
|
|
|
public function getEanFieldName() |
|
85
|
|
|
{ |
|
86
|
|
|
return $this->scopeConfig->getValue(self::CONFIG_EAN_FIELD); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @return string |
|
91
|
|
|
*/ |
|
92
|
|
|
public function getOrderPrefix() |
|
93
|
|
|
{ |
|
94
|
|
|
return $this->scopeConfig->getValue(self::CONFIG_ORDER_PREFIX); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @return bool |
|
99
|
|
|
*/ |
|
100
|
|
|
public function isImagesSyncEnabled() |
|
101
|
|
|
{ |
|
102
|
|
|
return (bool) $this->scopeConfig->getValue(self::CONFIG_IMAGES_SYNC); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* @return bool |
|
107
|
|
|
*/ |
|
108
|
|
|
public function isImagesSyncCronEnabled() |
|
109
|
|
|
{ |
|
110
|
|
|
return (bool) $this->scopeConfig->getValue(self::CONFIG_IMAGES_CRON_SYNC); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
public function filterProcessedProducts() |
|
114
|
|
|
{ |
|
115
|
|
|
return (bool) $this->scopeConfig->getValue(self::CONFIG_IMAGES_FILTER_PRODUCTS); |
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
|
|
|