1010
1111/**
1212 * Catalog product option select type
13+ *
14+ * @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
1315 */
1416class Select extends \Magento \Catalog \Model \Product \Option \Type \DefaultType
1517{
@@ -30,23 +32,35 @@ class Select extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
3032 */
3133 protected $ string ;
3234
35+ /**
36+ * @var array
37+ */
38+ private $ singleSelectionTypes ;
39+
3340 /**
3441 * @param \Magento\Checkout\Model\Session $checkoutSession
3542 * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
3643 * @param \Magento\Framework\Stdlib\StringUtils $string
3744 * @param \Magento\Framework\Escaper $escaper
3845 * @param array $data
46+ * @param array $singleSelectionTypes
3947 */
4048 public function __construct (
4149 \Magento \Checkout \Model \Session $ checkoutSession ,
4250 \Magento \Framework \App \Config \ScopeConfigInterface $ scopeConfig ,
4351 \Magento \Framework \Stdlib \StringUtils $ string ,
4452 \Magento \Framework \Escaper $ escaper ,
45- array $ data = []
53+ array $ data = [],
54+ array $ singleSelectionTypes = []
4655 ) {
4756 $ this ->string = $ string ;
4857 $ this ->_escaper = $ escaper ;
4958 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+ ];
5064 }
5165
5266 /**
@@ -310,10 +324,6 @@ public function getOptionSku($optionValue, $skuDelimiter)
310324 */
311325 protected function _isSingleSelection ()
312326 {
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 );
318328 }
319329}
0 commit comments