ci sono un paio di modifiche da fare al core di virtuemart e un paio di file tpl da creare, non conosco benissimo virtuemart quindi mi sono basato sulla gestione degli elementi per estrapolare il codice, detto questo passiamo agli step:
bisogna modificare il file administrator/components/com_virtuemart/classes/
ps_product_attribute.php
e aggiungere la funzione list_attribute_color (l'ho creata basandomi su list_attribute):
function list_attribute_color( $product_id ) {
global $VM_LANG, $CURRENCY_DISPLAY, $mm_action_url, $sess ;
require_once (CLASSPATH . 'ps_product.php') ;
$ps_product = new ps_product( ) ;
$Itemid = $sess->getShopItemid() ;
$category_id = vmGet( $_REQUEST, 'category_id', "" ) ;
$db = new ps_DB( ) ;
$db_sku = new ps_DB( ) ;
$db_item = new ps_DB( ) ;
$tpl = new $GLOBALS['VM_THEMECLASS']( ) ;
$tpl->set( "cls_suffix", $cls_suffix ) ;
$tpl->set( "product_id", $product_id ) ;
// Get list of children
$q = "SELECT product_id,product_name,product_full_image FROM #__{vm}_product WHERE product_parent_id='$product_id' AND product_publish='Y'" ;
$db->query($q);
if( $db->num_rows() > 0 ) {
$flypage = $ps_product->get_flypage( $product_id ) ;
$html = "<div name=\"product_id\" value=\"$product_id\" />" ;
$html .= "<span>" . $VM_LANG->_( 'PHPSHOP_PLEASE_SEL_COLOR' ) . "</span>: <br />\n" ;
while( $db->next_record() ) {
$html .= "<div style=\"width:20px;height:20px;float:left;margin-right:5px;border: 2px solid #FFFFFF; background-color:#".$db->f( "product_name" ).";\"><a href=\"components/com_virtuemart/shop_image/product/".$db->f( "product_full_image" )."\" style=\"width:100%;height:100%;display:block;\" rel=\"lightbox[product2]\"></a></div>";
}
$html .= "</div>\n " ;
$tpl->set( "select_color", $html ) ;
} else {
$html = "<div name=\"product_id\" value=\"$product_id\" />" ;
$html .= "</div>\n " ;
$tpl->set( "select_color", $html ) ;
}
$html = $tpl->fetch( 'product_details/includes/select_color.tpl.php' ) ;
return array( $html , "drop" ) ;
}
e bisogna aggiungere ai file di lingua in administrator/components/com_virtuemart/languages/common la costante PHPSHOP_PLEASE_SEL_COLOR con il testo che preferite tipo "Visualizza colori differenti"