10
10
11
11
/**
12
12
* Catalog product option select type
13
+ *
14
+ * @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
13
15
*/
14
16
class Select extends \Magento \Catalog \Model \Product \Option \Type \DefaultType
15
17
{
@@ -30,23 +32,35 @@ class Select extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
30
32
*/
31
33
protected $ string ;
32
34
35
+ /**
36
+ * @var array
37
+ */
38
+ private $ singleSelectionTypes ;
39
+
33
40
/**
34
41
* @param \Magento\Checkout\Model\Session $checkoutSession
35
42
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
36
43
* @param \Magento\Framework\Stdlib\StringUtils $string
37
44
* @param \Magento\Framework\Escaper $escaper
38
45
* @param array $data
46
+ * @param array $singleSelectionTypes
39
47
*/
40
48
public function __construct (
41
49
\Magento \Checkout \Model \Session $ checkoutSession ,
42
50
\Magento \Framework \App \Config \ScopeConfigInterface $ scopeConfig ,
43
51
\Magento \Framework \Stdlib \StringUtils $ string ,
44
52
\Magento \Framework \Escaper $ escaper ,
45
- array $ data = []
53
+ array $ data = [],
54
+ array $ singleSelectionTypes = []
46
55
) {
47
56
$ this ->string = $ string ;
48
57
$ this ->_escaper = $ escaper ;
49
58
parent ::__construct ($ checkoutSession , $ scopeConfig , $ data );
59
+
60
+ $ this ->singleSelectionTypes = $ singleSelectionTypes ?: [
61
+ 'drop_down ' => \Magento \Catalog \Api \Data \ProductCustomOptionInterface::OPTION_TYPE_DROP_DOWN ,
62
+ 'radio ' => \Magento \Catalog \Api \Data \ProductCustomOptionInterface::OPTION_TYPE_RADIO ,
63
+ ];
50
64
}
51
65
52
66
/**
@@ -310,10 +324,6 @@ public function getOptionSku($optionValue, $skuDelimiter)
310
324
*/
311
325
protected function _isSingleSelection ()
312
326
{
313
- $ single = [
314
- \Magento \Catalog \Api \Data \ProductCustomOptionInterface::OPTION_TYPE_DROP_DOWN ,
315
- \Magento \Catalog \Api \Data \ProductCustomOptionInterface::OPTION_TYPE_RADIO ,
316
- ];
317
- return in_array ($ this ->getOption ()->getType (), $ single );
327
+ return in_array ($ this ->getOption ()->getType (), $ this ->singleSelectionTypes , true );
318
328
}
319
329
}
0 commit comments