Skip to content

Commit

Permalink
🔃 [Magento Community Engineering] Community Contributions - 2.2-develop
Browse files Browse the repository at this point in the history
Accepted Public Pull Requests:
 - magento#22799: Disable Travis builds - 2.2-develop (by @okorshenko)
 - magento#21748: [Backport] Custom option type select - Allow modify list of single selection option types (by @ihor-sviziev)
  • Loading branch information
magento-engcom-team authored May 12, 2019
2 parents 834f1af + 6a83c2e commit eaf875e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
- [ ] Pull request has a meaningful description of its purpose
- [ ] All commits are accompanied by meaningful commit messages
- [ ] All new or changed code is covered with unit/integration tests (if applicable)
- [ ] All automated tests passed successfully (all builds on Travis CI are green)
- [ ] All automated tests passed successfully (all builds are green)
File renamed without changes.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[![Build Status](https://travis-ci.org/magento/magento2.svg?branch=2.2-develop)](https://travis-ci.org/magento/magento2)
[![Open Source Helpers](https://www.codetriage.com/magento/magento2/badges/users.svg)](https://www.codetriage.com/magento/magento2)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/magento/magento2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Crowdin](https://d322cqt584bo4o.cloudfront.net/magento-2/localized.png)](https://crowdin.com/project/magento-2)
Expand Down
20 changes: 14 additions & 6 deletions app/code/Magento/Catalog/Model/Product/Option/Type/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,35 @@ class Select extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
*/
protected $string;

/**
* @var array
*/
private $singleSelectionTypes;

/**
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Framework\Stdlib\StringUtils $string
* @param \Magento\Framework\Escaper $escaper
* @param array $data
* @param array $singleSelectionTypes
*/
public function __construct(
\Magento\Checkout\Model\Session $checkoutSession,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Framework\Stdlib\StringUtils $string,
\Magento\Framework\Escaper $escaper,
array $data = []
array $data = [],
array $singleSelectionTypes = []
) {
$this->string = $string;
$this->_escaper = $escaper;
parent::__construct($checkoutSession, $scopeConfig, $data);

$this->singleSelectionTypes = $singleSelectionTypes ?: [
\Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_DROP_DOWN,
\Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_RADIO,
];
}

/**
Expand Down Expand Up @@ -301,10 +313,6 @@ public function getOptionSku($optionValue, $skuDelimiter)
*/
protected function _isSingleSelection()
{
$single = [
\Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_DROP_DOWN,
\Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_RADIO,
];
return in_array($this->getOption()->getType(), $single);
return in_array($this->getOption()->getType(), $this->singleSelectionTypes, true);
}
}
8 changes: 8 additions & 0 deletions app/code/Magento/Catalog/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1164,4 +1164,12 @@
</argument>
</arguments>
</type>
<type name="Magento\Catalog\Model\Product\Option\Type\Select">
<arguments>
<argument name="singleSelectionTypes" xsi:type="array">
<item name="drop_down" xsi:type="const">Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_DROP_DOWN</item>
<item name="radio" xsi:type="const">Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_RADIO</item>
</argument>
</arguments>
</type>
</config>

0 comments on commit eaf875e

Please sign in to comment.