title: Magento Get Option Label by Option Code
body: <p>I need to get the <strong>Custom Option Label</strong> based on either the <em>Option ID</em> or <em>Option Code</em>.  Here's what I have so far:</p>
  <pre><code>$product_id = $product-&gt;getId(); //Get the Product Id
  echo '&lt;br /&gt;&lt;strong&gt;Product ID:&lt;/strong&gt; ' . $product_id;
  
  foreach($product-&gt;getCustomOptions() as $o) {
      echo '&lt;br /&gt;[Item ID] ' . $o-&gt;getItemId() . '&lt;br /&gt;[Value ID] ' . $o-&gt;getId() . '&lt;br /&gt;[Value] ' . $o-&gt;getValue() . '&lt;br /&gt;[Code] ' . $o-&gt;getCode() . '&lt;br /&gt;';
  }
  </code></pre>
  <p>So what I have to work with at this point is:</p>
  <blockquote>
  <p>Item ID</p>
  <p>Value ID</p>
  <p>Value</p>
  <p>Code</p>
  </blockquote>
  <p>My end goal is to use the option frontend label to see if the label is equal to &quot;Length&quot; as I am trying to use the &quot;Length&quot; value but seeing how custom options all have unique codes, the code is unreliable in terms of fetching just the &quot;length&quot; values for each item in the cart.</p>
  <p>How can I use what I have to get the label for the custom options?</p>
  <p>Thank you in advance!</p>