Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom option type select - Allow modify list of single selection option types #21744

Conversation

ihor-sviziev
Copy link
Contributor

Description (*)

When I wanted to add one more type for "select" option group:
screenshot1
But there is no ability to mark own custom option type as "single select".

This PR adds ability to add own custom option type to this list by adding following code to di.xml file of own module:

    <type name="Magento\Catalog\Model\Product\Option\Type\Select">
        <arguments>
            <argument name="singleSelectionOptionTypes" xsi:type="array">
                <item name="my_custom_option_type" xsi:type="const">VendorName\ModuelName\Model\PathToMyModel::OPTION_TYPE_MY_CUSTOM_OPTION_TYPE</item>
            </argument>
        </arguments>
    </type>

This method is used in a lot of places, for example during validating custom option values during adding product to cart.

Fixed Issues (if relevant)

N/A

Manual testing scenarios (*)

N/A

Contribution checklist (*)

  • 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)

@magento-engcom-team
Copy link
Contributor

Hi @ihor-sviziev. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@rodrigowebjump rodrigowebjump self-requested a review March 14, 2019 12:48
@ihor-sviziev ihor-sviziev force-pushed the custom-option-select-allow-modify-single-selection-list branch from 42f73ee to e3eedf1 Compare March 14, 2019 13:03
@ihor-sviziev
Copy link
Contributor Author

Hi @rodrigowebjump,
Looks like you approved PR to 2.2-develop branch twice, but didn’t approved this one

@magento-engcom-team
Copy link
Contributor

Hi @rodrigowebjump, thank you for the review.
ENGCOM-4588 has been created to process this Pull Request

@p-bystritsky p-bystritsky self-assigned this Apr 12, 2019
@nmalevanec nmalevanec self-assigned this Apr 12, 2019
@p-bystritsky p-bystritsky removed their assignment Apr 12, 2019
$this->singleSelectionTypes = $singleSelectionTypes ?: [
\Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_DROP_DOWN,
\Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_RADIO,
];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ihor-sviziev, could you please clarify, why we need default values here, cause we already have them in di.xml?
Also, here we have numeric array, and in di.xml we have associative array for default values.

Copy link
Contributor Author

@ihor-sviziev ihor-sviziev Apr 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @nmalevanec,
It's needed for backward compatiblity, when last argument will not be sent. For instance when someone extended this class in his code when this attribute was missing.

About numeric array VS associative array - ok, will unify them

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ihor-sviziev , consider defining default arguments in the di.xml, with this approach this parameter will become configurable instead of hardcoded.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sidolov,
As we discussed in Slack - it's needed for backward compatibility, in case if someone will extend this class & will not pass last argument in parent::__construct(...) - we have to have default value, similar as we're getting object from object manager by fallback.

…ions type

Make associative array as a default value in constructor
$this->singleSelectionTypes = $singleSelectionTypes ?: [
\Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_DROP_DOWN,
\Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_RADIO,
];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ihor-sviziev , consider defining default arguments in the di.xml, with this approach this parameter will become configurable instead of hardcoded.

@ghost ghost assigned sidolov Apr 22, 2019
@ghost ghost removed the Progress: accept label Apr 22, 2019
@ihor-sviziev ihor-sviziev requested a review from sidolov April 26, 2019 08:28
@magento-engcom-team
Copy link
Contributor

Hi @sidolov, thank you for the review.
ENGCOM-4588 has been created to process this Pull Request

@m2-assistant
Copy link

m2-assistant bot commented May 8, 2019

Hi @ihor-sviziev, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

taskula pushed a commit to Hypernova-Oy/magento2 that referenced this pull request May 8, 2019
@magento-engcom-team magento-engcom-team added this to the Release: 2.3.3 milestone May 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants