I am trying to show all the products with their custom options in a magento grid in admin panel. I can not figure out how to do this. I have to show products in grid and their custom options , if a product has 2 custom options then another row will show up for both custom options. All custom options are of drop down types. Any help will be appreciated. Thanks Alot

2 Answers 2


Here Below code using custom options get and select option to easily set

$customOptions = $objectManager->get('Magento\Catalog\Model\Product\Option')->getProductOptionCollection($_product);

    foreach($customOptions as $optionKey => $optionVal):
                   foreach($optionVal->getValues() as $valuesKey => $valuesVal) {
                          echo $valuesVal->getId().' '.$valuesVal->getTitle();
  • thanks for your answer, but i have to show the collection in the UI grid along with all the products Commented Jan 2, 2019 at 13:24
  • you can use also grid render webkul.com/blog/… Commented Jan 2, 2019 at 13:27
  • yes renderer is an option but then it will be an issue to manage the custom options in multiple rows Commented Jan 2, 2019 at 13:45
  • if you are used render then easily to manage select option Commented Jan 3, 2019 at 9:15

Declare \Magento\Catalog\Model\Product\Option in construct of your class.

Try following snippet:

protected $productOption;

public function __construct(
    \Magento\Catalog\Model\Product\Option $productOption
    $this->productOption = $productOption;

Then you can do following:

 * [$_product Product Object]
$customOptions = $this->productOption->getProductOptionCollection($_product);
if (!empty($customOptions->getData())) {
    foreach ($customOptions->getData() as $option) {
       print_r($option); // You will get option data here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.