Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Highlight Some Option Choices
 
zep007
Sr. Member
 
Avatar
Total Posts:  131
Joined:  2008-05-15
Connecticut
 

On the product page, I would like some options in a dropdown highlighted to show the product ships quicker with this configuration.  I know I can get the highlighting done with the HTML

<option value="1357" style="background-color: yellow;">
, so I thought I could do this dynamically.

I looked at app\design\frontend\default\default\template\catalog\product\view\select.phtml thinking I could do a case statement to highlight any options that contained a certain word (not the most flexible, I know) but when I do a little digging I see the options are called from the following :

<?php  $_option $this->getOption() ?> 
<dd<?php if ($_option->decoratedIsLast){?> class="last"<?php }?>>
    
<?php echo $this->getValuesHtml() ?>

so I can’t effect the build of the the option HTML this way (

<option value="1358">Wave Poppy 714 +$99.00</option>
)

Where would I find the file that builds this dropdown box option set?  And any suggestions for making this better are always welcomed, Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Discovery
Enthusiast
 
Total Posts:  767
Joined:  2007-12-29
 

Prototype - it’s all done in Javascript. That does not mean you cannot put your own Javascript in to do it. A recent colour picker wiki article has the clues you need.

 
Magento Community Magento Community
Magento Community
Magento Community
 
zep007
Sr. Member
 
Avatar
Total Posts:  131
Joined:  2008-05-15
Connecticut
 

Well, I took a look at the Wiki Article, doesn’t seem like it offers any insight into what Im looking to do.  Im not trying to set the value on these boxes, but just want to do a php switch to change the actual HTML inside the dropdown box. 

so instead of the option tag being like this: <option value="1357"> BLAH</option>

It looks like this: <option value="1357" style="background-color: yellow;"> BLAH</option>

To create the highlighting effect, not to select the option.

so if I knew where the HTML was built ‘for each’ option that is available, I could insert my conditional and effectively highlight only the options that I need to.

What I really would like to know is what the following (taken from the above example) does

$this->getValuesHtml()

now I know it echos the dropdownbox, but where can I see where the actual HTML for the box is being built?

Any other suggestions?  Im really only looking for the file that does this (php phtml), Ill take it form there.

 
Magento Community Magento Community
Magento Community
Magento Community
 
zep007
Sr. Member
 
Avatar
Total Posts:  131
Joined:  2008-05-15
Connecticut
 

Ok, so it works now.  Instead of changing the way the options are built I throw

$this->getValuesHtml();

into a variable, explode the html tags, change it up, and slap it back together. 

Now here is my newest issue:
I cant get the manufacturer variable in the file /app/design/frontend/default/default/template/catalog/product/view/options/type/select.phtml
I need this so I dont highlight manufacturers that share the same fabric groups, but do not have a quick ship program.

I tried forms of $this->getAttributeText(’manufacturer’); and adding $_product = $this->getProduct(); or variances.

Could anyone tell me the string to drop in here to make the Manufacturer Attribute able to be used?

 
Magento Community Magento Community
Magento Community
Magento Community
 
crxman
Member
 
Total Posts:  57
Joined:  2008-11-14
 

Hello zep007 ,

I want to hide the price of each option for non registered user I also need info about $this->getValuesHtml()

Can you share the code you used ?

Thank in advance anh happy new year smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
dalberts69
Jr. Member
 
Avatar
Total Posts:  16
Joined:  2008-12-03
 

No one seems to want to respond to this so I will:

You can find the getValuesHtml() function in:

app\code\core\Mage\Catalog\Block\Product\View\Options\Type\Select.php

 
Magento Community Magento Community
Magento Community
Magento Community
 
purush
Jr. Member
 
Total Posts:  7
Joined:  2009-04-23
 
dalberts69 - 30 January 2009 06:14 PM

No one seems to want to respond to this so I will:

You can find the getValuesHtml() function in:

app\code\core\Mage\Catalog\Block\Product\View\Options\Type\Select.php

Hi,

How to bring the background color for the option values dynamically.

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
purush
Jr. Member
 
Total Posts:  7
Joined:  2009-04-23
 

Hi,

The below code is to bring the background-color of the option values according to the color attributes in the color dropdown.
Note: when adding the color you must give the appropriate names ,ie red, blue etc

if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DROP_DOWN{
                $select
->setName('options['.$_option->getid().']')
                  
                ->
addOption(''$this->__('-- Please Select --'));
                foreach (
$_option->getValues() as $_value{
                $select
->addOption(
                 
'"style="background-color:'.$_value->getTitle().';color:#F9F9F9""'.''.$_value->getOptionTypeId(),
                 
$_value->getTitle()
                 );
                

            }

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top