this is my code but when i echo count ($_product->getOptions()) output show 0

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $_product = $objectManager->get('Magento\Catalog\Model\Product')->load($productId); 
    foreach ($_product->getOptions() as $options) {
    $optionType = $options->getType();
    $optionTitle = implode('_', explode(" ", $options->getTitle()));

how i get the product custom option in the magento 2

1 Answer 1


You can fetch the product options using this code,

$_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $_objectManager->get('\Magento\Catalog\Model\Product')->load($productId);
$customOptions = $_objectManager->get('Magento\Catalog\Model\Product\Option')->getProductOptionCollection($product);

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.