re: Page Attributes with multiple values

Permalink 2 users found helpful
Hi guys,

I've set up my site so certain products can be grouped/categorised. I used the select attribute type, allowing multiple options to be chosen.

My problem is how do I check if the category value exists within the page attribute?

I am generally just using an if statement to check if the string exist and if so present some text and url. Its easy to have the one value, but not sure how to check when you have multiple values.

I tried this method to no affect:

<?php if ($c->getCollectionAttributeValue('category') == "Cats") { ?>

Thanks in advance.
cheers,
Ritch

 
pvernaglia replied on at Permalink Reply
pvernaglia
if ( issset($c->getCollectionAttributeValue(ATTRIBUTE_NAME)) {
  Do Something Here;
}


If the value is not null that if should let you do something
roa123 replied on at Permalink Reply
Thanks for the response..figured it out with using combination of foreach and if statements to check every value.
87up replied on at Permalink Reply
87up
Hello,

im having the same problem, could you please enlightened me on how you solved the problem. ? :)

thank you in advance.
SVijay replied on at Permalink Best Answer Reply
SVijay
Hi

Use foreach and if statement inside the foreach to check the values.
foreach($attributes as $attribute){
  if($attribute == "choose1"){
     do something
 }
}

Hope you understand
87up replied on at Permalink Reply
87up
Hello OpenJuiceVijay,

Thank you for your answer,

Very usefull. :)
SVijay replied on at Permalink Reply
SVijay
Hi 87up,

Can you mark it as answer?
87up replied on at Permalink Reply
87up
Hello OpenJuiceVijay,

I think roa123 need to mark it as an answer.