0

Cause I don't find an answer for my problem (posted HERE) I try to explain it in other way.

How can I get the Admin Label for Specificed Attribute Options?

With the code below I get the Current Store View's Label for Specificed Attribute but I need to change it to get the Admin Label.

I found THIS ARTICLE and THIS QUESTION but I don't understand what I have to do. How I have to change the code below?

Thanks.

$attrs  = $_product->setStoreFilter(0)->getTypeInstance(true)->getConfigurableAttributesAsArray($_product);
foreach($attrs as $attr) {
    if(
(0 == strcmp("finish", $attr['attribute_code']))||
(0 == strcmp("structure", $attr['attribute_code']))
) {

        $options    = $attr['values'];

        foreach($options as $option) {
            //var_dump($option);

            $__ll = str_replace(array('^', '$'), array('<span class="ll_macroattribute">', '</span>'), $option['store_label']);

            //print "{$option['store_label']}<br />";

            $filter = $option['store_label'];

            $macro = '';

            if ($filter[0] == '^'){

                            $macro = substr($filter, strpos($filter, "^")+1, strpos($filter, "$")-(strpos($filter, "^")+1));

            }

            $url = strtolower(str_replace(array('"', ' '), ' ', $macro).'_'.trim(str_replace('^'.$macro.'$', '', $option['store_label']))).'.jpg';

            $url = str_replace(' ', '', $url);
            $url = str_replace('è', 'e', $url);
            $url = str_replace('é', 'e', $url);
            $url = str_replace('à', 'a', $url);
            $url = str_replace('ì', 'i', $url);
            $url = str_replace('ò', 'o', $url);
            $url = str_replace('ù', 'u', $url);
            $url = str_replace("'", "", $url);

            array_push($newmenu, array("url" => $url, "filter" => '<span class="ll_macroattribute">'.trim(strtoupper(str_replace('^'.$macro.'$', '', $option['store_label']))).'</span><br>', "macro" => '<span class="ll_macroattribute" style="color:#666;">' . $macro . '</span>'));

            //echo $__ll.'<br>';

        }

    }

}
1

try this code

$attrbute_code = 'brand';
$brandLabel = $_product->getAttributeText($attrbute_code);
  • Thanks for your answer. Tonight I will try. Can you explain me how I have to modify the code that I posted? Thanks for your help. – Zig Jul 6 '14 at 9:04
  • I tried to make the changes indicated in this, and in other posts, but I don't get the desired result. What I would like is the Jpg file were searched with a name depending on the Option's Admin Label of the attributes listened in the "if". I don't know how to do it. Help please. – Zig Jul 7 '14 at 21:52
  • I don't find a solution yet..Can anyone help me please? Thanks – Zig Jul 14 '14 at 23:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.