Domanda

This My Code

$IsCustomizableColor =  $_product->getResource()->getAttribute('customizecolor')->getFrontend()->getValue($_product);
   <?php 
$SplitColor = explode (',', $IsCustomizableColor);
foreach($SplitColor as $color){?>
 <?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'Custom/'.$color.'.png'; ?>
<?php } ?>

it will print with space for second time first time it's fine

my output

http://localhost/Test/media/Custom/Black.png 
http://localhost/Test/media/Custom/ Green.png 
http://localhost/Test/media/Custom/ Yellow.png

what is the problem? How to fix this

È stato utile?

Soluzione

Replace your code with this :

$IsCustomizableColor =  $_product->getResource()->getAttribute('customizecolor')->getFrontend()->getValue($_product);
   <?php 
$SplitColor = explode (',', $IsCustomizableColor);
foreach($SplitColor as $color){?>
 <?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'Custom/'.trim($color).'.png'; ?>
<?php } ?>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top