0

I have a product with two groups of custom options and I want one group to appear in the "product info column" and the other to appear in the "block after info column".

Currently, on the product page > design tab there is only one option for the layout which controls where all product options display. There is no way to control this individually.

  • @hakre OK, I figured, since there was no way to do this via the admin panel, it had to be done in code, either using layout xml or phtml. – shnozolla Mar 20 '13 at 21:17
  • And did you find a solution? If so you can leave an answer below. If not, you can outline what you've tried so far in the question so it's clear where you're looking. – hakre Mar 20 '13 at 21:27
  • That might be the case, but we're welcoming both sort of questions here, especially in the grey area between programming and configuration where a lot of Magento development resides. – Alan Storm Mar 21 '13 at 3:33
1

This is not a very elegant solution - but if you must use custom options and you have access / ability to modify the theme I suggest the following:

  • Relocate container1 and container2 in your template - these are called via getChildChildHtml('',true,true) in the base theme

-or-

  • Name the options via a naming convention; e.g. "Region 1 - Option 1", "Region 2 - Option 2", etc.

  • In the template, parse the name of all options and store in two separate arrays to be output later.

For the second option - get a list of options from a product:

$product = Mage::getModel('catalog/product')->load($product_id);
$options = $product->getOptions();

Parse through the options and filter by naming convention:

$region1 = array();
$region2 = array();
foreach($options as $option){
    if($option->getType()!='drop_down'){
       if(stripos($option,'Region 1 - ')!==false){
            $region1[] = array_pop(explode('Region 1 - ', $option));
        } elseif(stripos($option,'Region 1 - ')!==false){
            $region2[] = array_pop(explode('Region 2 - ', $option));
        }
    }
}

Now loop over $region1 and $region2, echoing as you go.

foreach($region1 as $option){
    echo $option;
}
| improve this answer | |
  • Not so nice to do this parsing in the template. Better in a Block oder Helper class. – Alex May 14 '13 at 16:32
  • I don't disagree with you. @Alex – philwinkle May 14 '13 at 16:32

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.