0

I want to override custom options template file.I want to show static image with each option value. I just create a custom file in Catalog module but don't know how to achieve this task?

app/design/frontend/Occasionwear/m2-theme/Magento_Catalog/templates/product/view/custom.phtml

enter image description here

Need help. Thanks

5
  • 1
    What do you mean by values ? Can you describe more ?!
    – anonymous
    Nov 28, 2018 at 9:35
  • See screenshot. Need an image after each title. Nov 28, 2018 at 9:39
  • First thing is your path is wrong, You are trying to override adminhtml part and you've created file at frontend. First Try to find in core code which file is responsible for your red marked section than copy that file to your theme at exact same location. Than Customize it.
    – anonymous
    Nov 28, 2018 at 10:20
  • These options are displaying on front end.I just add a screenshot to understand. Nov 28, 2018 at 10:39
  • I ain't understanding your question.
    – anonymous
    Nov 28, 2018 at 10:48

1 Answer 1

0

using the below code you can get custom attribute value in phtml file.

    $_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $_product = $_objectManager->create('Magento\Catalog\Mode\Product')->load($_product->getId());
    $customOptions = $_objectManager->get('Magento\Catalog\Model\Produc\Option')->getProductOptionCollection($_product);

    foreach($customOptions as $option){
        $values = $option->getValues();
        if (empty($values)) { 
           continue;
        }?>
        <div class="custome-option">
        <?php
        foreach($values as $value){ ?>
            <span><?php echo $value->getTitle(); ?></span>
            <?php
        } ?>
        </div>
        <?php 
    }
0

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.