0

I am using magento 1.9.2.4. version. I added some custom option for my test product. Please check this screen short

But it's not showing in product view page

I also use this code in view.phtml

$productCollection = Mage::getModel("catalog/product")->load(1742);
$i = 1;
echo 'kkkk';
foreach ($productCollection->getOptions() as $value) {
echo "<strong>Custom Option:" . $i . "</strong><br/>";
echo "Custom Option TYPE: " . $value->getType() . "<br/>";
echo "Custom Option TITLE: " . $value->getTitle() . "<br/>";
echo "Custom Option Values: <br/>";
// Getting Values if it has option values, case of select,dropdown,radio,multiselect
$values = $value->getValues();
foreach ($values as $values) {
print_r($values->getData());
}
$i++;
} 

and this also

echo '<pre>';
if($product->hasOptions()) 
                        {
    foreach ($product->getOptions() as $o) {
        $optionType = $o->getType();
        echo 'Type = '.$optionType;

        if ($optionType == 'drop_down') {
            $values = $o->getValues();

            foreach ($values as $k => $v) {
                print_r($v);
            }
        }
        else {
            print_r($o);
        }
    }    
}
echo '</pre>';

But nothing is happened. And the same code is working fine on xmapp. please guide me. I am new in magento.

  • by default, magento display custom options, no need to use any code.... check the qty , make sure its more than 0 also check in-stock is set , also check product by switching to other themes like default, blank..... – Baby in Magento Jan 16 '17 at 7:02
  • I check it again. product is in stoke and qty is 50. product are display fine and to cart properly. Please suggest the me what i do next dear@BabyinMagento – bansal kapil Jan 16 '17 at 7:16
  • please check by switching to different themes under Design > Custom Design – Baby in Magento Jan 16 '17 at 7:18
  • please share the product url so we check and guide you – Jigs Parmar Oct 4 '18 at 11:04
0

Try the below code in Product detail page.

    $_product = Mage::registry('current_product');
    $product = Mage::getModel('catalog/product')->load($_product->getId());
    foreach($product->getOptions() as $option) {
        if ($option->getTitle() == "test") {
            foreach($option->getValues() as $value) {
                Mage::log($value->getPrice(), null, 'price.log');
            }
        }
    }

In if condition I have filtered by title name. The same way you can filter and you can get your values

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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