-
Notifications
You must be signed in to change notification settings - Fork 9
/
Data.php
258 lines (235 loc) · 6.34 KB
/
Data.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
<?php
/**
* EkomiIntegration Helper
*
* @category Ekomi
* @copyright Copyright (c) 2019 Ekomi ltd (http://www.ekomi.de)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace Ekomi\EkomiIntegration\Helper;
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Store\Model\ScopeInterface;
/**
* Class Data
*
* @package Ekomi\EkomiIntegration\Helper
*/
class Data extends AbstractHelper
{
const XML_PATH_SHOP_ID = 'ekomiintegration/general/shop_id';
const XML_PATH_SHOP_PASSWORD = 'ekomiintegration/general/shop_password';
const XML_PATH_PRODUCT_REVIEWS = 'ekomiintegration/general/product_reviews';
const XML_PATH_ORDER_STATUS = 'ekomiintegration/general/order_status';
const XML_PATH_ACTIVE = 'ekomiintegration/general/active';
const XML_PATH_REVIEW_MOD = 'ekomiintegration/general/review_mod';
const XML_PATH_IDENTIFIER = 'ekomiintegration/general/product_identifier';
const XML_PATH_EXCLUDE_IDS = 'ekomiintegration/general/exclude_products';
const XML_PATH_EXPORT_METHOD = 'ekomiintegration/general/export_method';
const XML_PATH_TURNAROUND_TIME = 'ekomiintegration/general/turnaround_time';
const XML_PATH_ACTIVE_PRC = 'ekomiintegration/prc/show_prc';
const XML_PATH_WIDGET_TOKEN = 'ekomiintegration/prc/widget_token';
const XML_PATH_STORE_NAME = 'trans_email/ident_support/name';
const XML_PATH_STORE_EMAIL = 'trans_email/ident_support/email';
const XML_PATH_TERMS_CONDITION = 'ekomiintegration/general/terms_and_conditions';
/**
* @var ScopeConfigInterface
*/
protected $scopeConfig;
/**
* Data constructor.
*
* @param ScopeConfigInterface $scopeConfig
*/
public function __construct(ScopeConfigInterface $scopeConfig)
{
$this->scopeConfig = $scopeConfig;
}
/**
* @param integer $storeId
* @return string ShopId
*/
public function getShopId($storeId = false)
{
return $this->getConfigValue(
self::XML_PATH_SHOP_ID,
$storeId
);
}
/**
* @param integer $storeId
* @return string ShopPassword
*/
public function getShopPw($storeId = false)
{
return $this->getConfigValue(
self::XML_PATH_SHOP_PASSWORD,
$storeId
);
}
/**
* @param integer $storeId
* @return bool ProductReviews
*/
public function getProductReview($storeId = false)
{
return $this->getConfigValue(
self::XML_PATH_PRODUCT_REVIEWS,
$storeId
);
}
/**
* @param integer $storeId
* @return string OrderStatuses (comma separated)
*/
public function getOrderStatus($storeId = false)
{
return (string)$this->getConfigValue(
self::XML_PATH_ORDER_STATUS,
$storeId
);
}
/**
* @param integer $storeId
* @return bool Active
*/
public function getIsActive($storeId = false)
{
return $this->getConfigValue(
self::XML_PATH_ACTIVE,
$storeId
);
}
/**
* @param integer $storeId
* @return string StoreName
*/
public function getStoreName($storeId = false)
{
return $this->getConfigValue(
self::XML_PATH_STORE_NAME,
$storeId
);
}
/**
* @param integer $storeId
* @return string StoreEmail
*/
public function getStoreEmail($storeId = false)
{
return $this->getConfigValue(
self::XML_PATH_STORE_EMAIL,
$storeId
);
}
/**
* @param integer $storeId
* @return string ReviewMod (email, sms, fallback)
*/
public function getReviewMod($storeId = false)
{
return $this->getConfigValue(
self::XML_PATH_REVIEW_MOD,
$storeId
);
}
/**
* @param integer $storeId
* @return string ProductIdentifier (id, sku)
*/
public function getProductIdentifier($storeId = false)
{
return $this->getConfigValue(
self::XML_PATH_IDENTIFIER,
$storeId
);
}
/**
* @param integer $storeId
* @return string ExcludeProducts (comma separated ids)
*/
public function getExcludeProducts($storeId = false)
{
return $this->getConfigValue(
self::XML_PATH_EXCLUDE_IDS,
$storeId
);
}
/**
* @param integer $storeId
* @return string ExportMethod
*/
public function getExportMethod($storeId = false)
{
return $this->getConfigValue(
self::XML_PATH_EXPORT_METHOD,
$storeId
);
}
/**
* @param integer $storeId
* @return integer TurnaroundTime
*/
public function getTurnaroundTime($storeId = false)
{
return $this->getConfigValue(
self::XML_PATH_TURNAROUND_TIME,
$storeId
);
}
/**
* @param integer $storeId
* @return bool ActivePrc
*/
public function getActivePrc($storeId = false)
{
return $this->getConfigValue(
self::XML_PATH_ACTIVE_PRC,
$storeId
);
}
/**
* @param integer $storeId
* @return string WidgetToken
*/
public function getWidgetToken($storeId = false)
{
return $this->getConfigValue(
self::XML_PATH_WIDGET_TOKEN,
$storeId
);
}
/**
* @param string $configPath
* @param integer $storeId
* @return bool|string
*/
private function getConfigValue($configPath, $storeId = false)
{
$storeScope = ScopeInterface::SCOPE_STORE;
if ($storeId) {
$value = $this->scopeConfig->getValue(
$configPath,
$storeScope,
$storeId
);
} else {
$value = $this->scopeConfig->getValue(
$configPath,
$storeScope
);
}
return $value;
}
/**
* @param null $storeId
* @return bool|string
*/
public function isTermsAndConditionsAccepted($storeId = null)
{
return $this->getConfigValue(
self::XML_PATH_TERMS_CONDITION,
$storeId
);
}
}