I try to explain my problem. I'm working with a Store created by other people and it's difficult to me understanding everything. The Store have a custom template and, in my view.phtml, I found the Code below. With this Code, for the specified Attributes, I have a New Tab (called "Finiture") in the Product Details. In this Tab are displayed the images of the Finishes (colors and materials) that are searched based on the Store View's Label. This is the problem! For each Store View I have to put (in catalog/media/finiture) a .jpg file. So I have 2 or 3 copy of the same file with a different names. I want instead the images be searched based on the Admin Label. With this change I can put (in catalog/media/finiture) only one .jpg file for each Row. How can I made this change? Thanks to everyone.
<div id="tabs-6" class="tab-item">
<?php
if ($_product->isSaleable() && $this->hasOptions()):
$newmenu = array();
$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>';
}
}
}
$last = '';
$out = '';
if (count($newmenu) < 1 )
echo '
<style>
#tab_finiture { display:none;}
</syle>
';
foreach ($newmenu as $row){
$row['url'] = str_replace('è', 'e', $row['url']);
if (($last != $row['macro'])&&($last==''))
{
$last = $row['macro'];
$out .= '<div style="clear:both;margin-bottom:10px;">';
$out .= '<div style="float:left;width:145px;min-height:70px;">'.$row['macro'].'</div>';
$out .= '<div style="float:left;width: 570px;">';
$file = 'http://www.mywebsite.com/media/catalog/finish/'.$row['url'];
$file_headers = @get_headers($file);
if($file_headers[0] == 'HTTP/1.1 404 Not Found') {
$url = '';
}
else {
$url = '<img src="http://www.mywebsite.com/media/catalog/finish/'.$row['url'].'" style="border:none;width:160px;height:160px;">';
}
$out .= '<div style="float:left;width:190px;min-height:190px;">'.$row['filter'].$url.'</div>';
}
elseif (($last != $row['macro'])&&($last!=''))
{
$last = $row['macro'];
$out .= '</div><div style="clear:both;"></div></div>';
$out .= '<div style="clear:both;margin-bottom:10px;">';
$out .= '<div style="float:left;width:145px;min-height:70px;">'.$row['macro'].'</div>';
$out .= '<div style="float:left;width: 570px;">';
$file = 'http://www.mywebsite.com/media/catalog/finish/'.$row['url'];
$file_headers = @get_headers($file);
if($file_headers[0] == 'HTTP/1.1 404 Not Found') {
$url = '';
}
else {
$url = '<img src="http://www.mywebsite.com/media/catalog/finish/'.$row['url'].'" style="border:none;width:160px;height:160px;">';
}
$out .= '<div style="float:left;width:190px;min-height:190px;">'.$row['filter'].$url.'</div>';
}else{
if (($last!='')){
$file = 'http://www.mywebsite.com/media/catalog/finish/'.$row['url'];
$file_headers = @get_headers($file);
if($file_headers[0] == 'HTTP/1.1 404 Not Found') {
$url = '';
}
else {
$url = '<img src="http://www.mywebsite.com/media/catalog/finish/'.$row['url'].'" style="border:none;width:160px;height:160px;">';
}
$out .= '<div style="float:left;width:190px;min-height:190px;">'.$row['filter'].$url.'</div>';
}else{
$out .= '<div style="clear:both;margin-bottom:10px;">';
$out .= '<div style="float:left;width:190px;min-height:190px;">'.$row['macro'].'</div>';
$out .= '<div style="float:left;width: 600px;">';
$file = 'http://www.mywebsite.com/media/catalog/finish/'.$row['url'];
$file_headers = @get_headers($file);
if($file_headers[0] == 'HTTP/1.1 404 Not Found') {
$url = '';
}
else {
$url = '<img src="http://www.mywebsite.com/media/catalog/finish/'.$row['url'].'" style="border:none;width:160px;height:160px;">';
}
$out .= '<div style="float:left;width:190px;min-height:190px;">'.$row['filter'].$url.'</div>';
}
}
/*
var_dump($row['macro']);
echo '<br>';
var_dump($row['filter']);
echo '<br>';
var_dump(count($row['filter']));
echo'<br><br>################<br>';
*/
}
$out .= '</div></div>';
$out .= '<div style="clear:both;"></div>';
echo $out;
endif;
?>
</div>