Get select attribute value by Query String OR ID....

Permalink 1 user found helpful
Hi there,

I'm trying to implement something for the purposes of SEO. This is when we have a 'tag' search results page, we want to grab the attribute ID that produced this page (ie someone clicks a tag, it takes you to search results page, and we insert tag name in page title).

We have a url that ends with '?akID[21][atSelectOptionID][]=19'

So obviously our akID = 21 and the atSelectOptionID = 19.

So how do i get the value (ie the 'name') of that particular option?

Is there a better way to do this?

Many thanks!

View Replies:
drbiskit replied on at Permalink Reply
Hi - Did you ever work out how to do this at all? Just trying to work it out as well.

jpcharrier replied on at Permalink Reply
Hey yes I did actually!

This is the code I used, we have placed this in the header of the site as we use tags throughout. You could also abstract this out to a function if you wanted.

// Tag Search variables
   // Here we grab the tag that was clicked and get the name 'value'
   if (is_array($_REQUEST['akID'])) {
      foreach($_REQUEST['akID'] as $key => $value) {
         $fak = CollectionAttributeKey::getByID($key);
         $satc = new SelectAttributeTypeController(AttributeType::getByHandle('select'));
         $values = $satc->getOptions();
         if(count($values) > 1) {
            $tagName = array();
            foreach ($value as $V) {
               foreach ($V as $option) {
                  $tagName = SelectAttributeTypeOption::getByID($option);

Hope that helps!
drbiskit replied on at Permalink Reply
Yeah, nicely done + thanks for providing this, very useful.

I had ended up using the querystring which did the job for what I needed, but this is much better of doing things...