Retrieve all available system options type for bundle products Magento 2.

Bundle product generated using options type like dropdown, radio, checkbox, multi-select. You can get all native system option types for bundle products programmatically.

If you want to know about all the available options type in the system, You can use a native interface.
Magento\Bundle\Api\ProductOptionTypeListInterface

Interface contains the getItems() method to display list of options for the bundle product.

<?php
namespace Jesadiya\BundleOptions\Model;

use Magento\Bundle\Api\Data\OptionTypeInterface;
use Magento\Bundle\Api\ProductOptionTypeListInterface;

class BundleOptions
{
    /**
     * @var ProductOptionTypeListInterface
     */
    private $productOptionType;

    public function __construct(
        ProductOptionTypeListInterface $productOptionType
    ) {
        $this->productOptionType = $productOptionType;
    }

    /**
     * option type of bundle products
     *
     * @return OptionTypeInterface[]
     */
    public function getOptionsType()
    {
        $items = $this->productOptionType->getItems();

        return $items;
    }
}

Call from the template or any PHP class,

$items = $this->getOptionsType();

foreach ($items as $item) {
    echo $item->getLabel(). '=>' .$item->getCode();
}

  • Output:
    Drop-down => select
    Radio Buttons => radio
    Checkbox => checkbox
    Multiple Select => multi