Back to top

Autore Topic: [RISOLTO] Aumentare Prodotti correlati  (Letto 1082 volte)

Offline munick

  • Appassionato
  • ***
  • Post: 335
    • Mostra profilo
[RISOLTO] Aumentare Prodotti correlati
« il: 21 Mag 2011, 15:47:58 »
Salve,

vi espongo un quesito semplice...

Visualizzo solamente 4 prodotti correlati, (è normale).
Come incremento questo numero????


Grazie...
« Ultima modifica: 21 Mag 2011, 18:04:27 da munick »

Offline munick

  • Appassionato
  • ***
  • Post: 335
    • Mostra profilo
[RISOLTO] Aumentare Prodotti correlati
« Risposta #1 il: 21 Mag 2011, 16:30:35 »
Salve,

vi espongo un quesito semplice...

Visualizzo solamente 4 prodotti correlati, (è normale).
Come incremento questo numero????


Grazie...

Ragazzi, ho trovato la soluzione...

Spero proprio sia utile ad altri...


OK, for those of you that want to display related products on multiple rows, this is how you do it...

1. You need to set the limit of how many related products you want to display. The default if 4.

In the file:
administrator\components\com_virtuemart\html\shop.product_details.php

at about Line 85 you will find the following code:
$q .= "AND FIND_IN_SET(#__{vm}_product.product_id, REPLACE(related_products, '|', ',' )) LIMIT 0, 4";

Change the 4 in : LIMIT 0, 4"; to limit the number of related products to whatever you want.

2. Next you need to set the number of products to display per row.

To do this you can apply the following hack to the relatedProducts.tpl.php file:
/components/com_virtuemart/themes/default/templates/common/relatedProducts.tpl.php

Replace the table code that reads:

<table width="100%" align="center">
   <tr>
    <?php
    while( $products->next_record() ) { ?>
         <td valign="top">
            <?php echo $ps_product->product_snapshot( $products->f('product_sku') ) ?>
         </td>
   <?php
    }
   ?>
    </tr>
</table>

With the following:

<table align="center" width="100%">
<tr>
    <?php
    define("MAX_PER_ROW", 2);
    $more_products = $products->next_record();
    $current_product = 0;
    while( $more_products ) {
     if ($current_product == 0)
     {
 ?>
 <tr>
 <?php
     }
        while ($more_products && $current_product < MAX_PER_ROW)
        {
 ?>
   
         <td valign="top">
            <?php echo $ps_product->product_snapshot( $products->f('product_sku') ) ?>
         </td>
   <?php
      $current_product++;
      $more_products = $products->next_record();
     
        if ($current_product == MAX_PER_ROW || !$more_products)
        {
           $current_product = 0;
        ?>
        </tr>
        <?
        }
     }
     
}
   ?>
    </tr>
</table>

Using the MAX_PER_ROW constant you can then set the number of related products per row to whatever suits you.

 



Web Design Bolzano Kreatif