Foros
Productos ALEATORIOS en oscommerce

Autor Fecha: 21 de Octubre del 2006 a las 13:03:40   Descripción: Productos ALEATORIOS en oscommerce
Sin avatar
Sexo: Masculino
País:
Mensajes: 189
Hola a toda la magnifica comunidad de ZONA-OCIO,.

Ahora vuelvo a las preguntas y en cada una de mis preguntas y dudas has sido respondidas con una rapidez increible y sobre todo con una exactitud y certeza magnifica.

Ahora expongo una duda mas y creo que esta es la mas atrevida porque considero que lleva mas tiempo y analisis. solo espero no cansar a la comunidad ni a adolfo..... quien es el que me ha respondido a todo.(gracias) Muy bien

Antes de iniciar, Adolfo, gracias por la ayuda prestada y en este caso no se si sea demasiado lo que pregunto. Ayuda

resulta que tengo un archivo para que en OSCOMMERCE los pruductos de la pagina inicial esten cambiando aleatoriamente, FUNCIONA DE MARAVILLA, el problema es que no me muestra el diseño original ya que tengo un template de template monster, no muestra los botones de agregar al carrito ni una imagen pequeña ni la descripcion del producto.

Este es el codigo del archivo ORIGINAL (new_products.php)

Código
<?php
/*
  edited - 2005/07/01 13&#58;50

  -----------------------------------------

  $Id&#58; new_products.php,v 1.34 2003/06/09 22&#58;49&#58;58 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http&#58;//www.oscommerce.com

  Copyright &#40;c&#41; 2003 osCommerce

  Released under the GNU General Public License
*/
?>
<!-- new_products //-->
<?php

  if &#40; &#40;!isset&#40;$new_products_category_id&#41;&#41; || &#40;$new_products_category_id == '0'&#41; &#41; &#123;
    $new_products_query = tep_db_query&#40;"select p.products_id, p.products_image, p.products_tax_class_id, if&#40;s.status, s.specials_new_products_price, p.products_price&#41; as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS&#41;;
  &#125; else &#123;
    $new_products_query = tep_db_query&#40;"select distinct p.products_id, p.products_image, p.products_tax_class_id, if&#40;s.status, s.specials_new_products_price, p.products_price&#41; as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . &#40;int&#41;$new_products_category_id . "' and p.products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS&#41;;
  &#125;

  $row = 0;
  $col = 0;


  echo '
      <table cellspacing=0 cellpadding=0 width=519>
       <tr><td colspan=3 bgcolor=#F5F5F5 height=31 style="padding-left&#58; 9px"><img src=images/m16.gif width=13 height=12>&nbsp;<span class=ch2>Today's special Offers</span></td></tr>  
       <tr><td height=9></td></tr>
       <tr>
           ';

  while &#40;$new_products = tep_db_fetch_array&#40;$new_products_query&#41;&#41; &#123;
   $new_products&#91;'products_name'&#93; = tep_get_products_name&#40;$new_products&#91;'products_id'&#93;&#41;;
   $product_query = tep_db_query&#40;"select products_description  from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . &#40;int&#41;$new_products&#91;'products_id'&#93; . "' and language_id = '" . &#40;int&#41;$languages_id . "'"&#41;;
   $product = tep_db_fetch_array&#40;$product_query&#41;;
   $new_products&#91;'products_description'&#93; = $product&#91;'products_description'&#93;;
   // get products category
   $categories_query = tep_db_query&#40;"select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . &#40;int&#41;$new_products&#91;'products_id'&#93; . "'"&#41;;
   if &#40;tep_db_num_rows&#40;$categories_query&#41; > 0&#41; &#123;
     $categories = tep_db_fetch_array&#40;$categories_query&#41;;
     $categories_query2 = tep_db_query&#40;"select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . &#40;int&#41;$categories&#91;'categories_id'&#93; . "'"&#41;;
     $categories2 = tep_db_fetch_array&#40;$categories_query2&#41;;
     $category_name = $categories2&#91;'categories_name'&#93;;
   &#125; else &#123;
     $category_name = '';
   &#125;
      // get products manufacturers
   $man_query = tep_db_query&#40;"select manufacturers_id from " . TABLE_PRODUCTS . " where products_id = '" . &#40;int&#41;$new_products&#91;'products_id'&#93; . "'"&#41;;
   if &#40;tep_db_num_rows&#40;$categories_query&#41; > 0&#41; &#123;
     $manuf = tep_db_fetch_array&#40;$man_query&#41;;
     $man_query2 = tep_db_query&#40;"select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . &#40;int&#41;$manuf&#91;'manufacturers_id'&#93; . "'"&#41;;
     $manuf2 = tep_db_fetch_array&#40;$man_query2&#41;;
     $man_name = $manuf2&#91;'manufacturers_name'&#93;;
   &#125; else &#123;
     $man_name = '';
   &#125;



   echo '

       <td width=259 valign=top>
        <table cellspacing=0 cellpadding=0 width=259>
         <tr><td width=115 align=center><a href="' . tep_href_link&#40;FILENAME_PRODUCT_INFO, 'products_id=' . $new_products&#91;'products_id'&#93;&#41; . '">' . tep_image&#40;DIR_WS_IMAGES . $new_products&#91;'products_image'&#93;, $new_products&#91;'products_name'&#93;, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'vspace=0'&#41; . '</a></td>
         <td width=144 valign=top>
          <table cellspacing=0 cellpadding=0 width=140>
           <tr><td height=1></td></tr>
           <tr><td height=35 class=ml3 style="padding-left&#58;4px" valign=middle><a class=ml3 href="' . tep_href_link&#40;FILENAME_PRODUCT_INFO, 'products_id=' . $new_products&#91;'products_id'&#93;&#41; . '"> ' . $man_name . '</a> <a class=ml5 href="' . tep_href_link&#40;FILENAME_PRODUCT_INFO, 'products_id=' . $new_products&#91;'products_id'&#93;&#41; . '"> ' . $new_products&#91;'products_name'&#93; . '</a></td></tr>
           <tr><td height=1></td></tr>
           <tr><td height=45 valign=middle  class=ch5><img src=images/m21.gif width=4 height=4 align=absmidle>&nbsp;<span class=ch3>'.preg_replace&#40;'/sS*$/i', '', substr&#40;$new_products&#91;'products_description'&#93;, 0, 60&#41;&#41;.' ...</span></td></tr>
           <tr><td height=15></td></tr>
           <tr><td class=ch4>&nbsp;Today only '.$currencies->display_price&#40;$new_products&#91;'products_price'&#93;, tep_get_tax_rate&#40;$new_products&#91;'products_tax_class_id'&#93;&#41;&#41;.'</td></tr>
           <tr><td height=10></td></tr>
           <tr><td><a href="' . tep_href_link&#40;FILENAME_PRODUCT_INFO, 'products_id=' . $new_products&#91;'products_id'&#93;&#41; . '">' . tep_image_button&#40;'small_view.gif'&#41; . '</a>&nbsp;<a href="' . tep_href_link&#40;basename&#40;$PHP_SELF&#41;, tep_get_all_get_params&#40;array&#40;'action'&#41;&#41; . 'action=buy_now&products_id=' . $new_products&#91;'products_id'&#93;&#41; . '">' . tep_image_button&#40;'button_in_cart.gif'&#41; . '</a></td></tr>
          </table>  
         </td></tr>
        </table>
       </td>


        ';
  
    $col ++;
    if &#40;$col > 1&#41; &#123;
      $col = 0;
      $row ++;
      echo '

       </tr>
       <tr><td height=5></td></tr>
       <tr><td colspan=3 height=1 align=center style="padding-left&#58; 1px">
        <table cellspacing=0 cellpadding=0 align=center>
         <tr><td background=images/m22.gif width=252 height=1></td>
         <td width=4></td>
         <td background=images/m22.gif width=252 height=1></td></tr>
        </table>
       </td></tr>
       <tr><td height=5></td></tr>
       <tr>



           ';
    &#125; else echo '
    <td background=images/m17.gif>
    <table cellspacing=0 cellpadding=0 width=1><tr>
    <td background=images/m17.gif width=1></td>
    </tr>
    </table></td>
     ';
  &#125;


  echo '

       </tr>
       <tr><td height=4></td></tr>
      </table>



       ';


?>
<!-- new_products_eof //-->


Y este es el archivo que permite los productos ALEATORIOS (new_products.php)

Código
<?php
/*
  $Id&#58; new_products.php,v 1.35 2004/02/05 15&#58;50&#58;00 adf Exp $
  Randomize New Products
  $Id&#58; new_products.php,v 1.34 2003/06/09 22&#58;49&#58;58 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http&#58;//www.oscommerce.com

  Copyright &#40;c&#41; 2003 osCommerce

  Released under the GNU General Public License
*/
?>
<!-- new_products //-->
<?php
  $info_box_contents = array&#40;&#41;;
  $info_box_contents&#91;&#93; = array&#40;'text' => sprintf&#40;TABLE_HEADING_NEW_PRODUCTS, strftime&#40;'%B'&#41;&#41;&#41;;

  new contentBoxHeading&#40;$info_box_contents&#41;;

  if &#40; &#40;!isset&#40;$new_products_category_id&#41;&#41; || &#40;$new_products_category_id == '0'&#41; &#41; &#123;
// start random new products
    $new_products_query = tep_db_query&#40;"select p.products_id, p.products_image, p.products_tax_class_id, if&#40;s.status, s.specials_new_products_price, p.products_price&#41; as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_date_added desc limit " . MAX_RANDOM_SELECT_NEW&#41;;
  &#125; else &#123;
    $new_products_query = tep_db_query&#40;"select distinct p.products_id, p.products_image, p.products_tax_class_id, if&#40;s.status, s.specials_new_products_price, p.products_price&#41; as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . &#40;int&#41;$new_products_category_id . "' and p.products_status = '1' order by p.products_date_added desc limit " . MAX_RANDOM_SELECT_NEW&#41;;
// end random new products    
  &#125;
// start random new products
  // To configure&#58;
  //
  // Under Admin - Configuration - Maximum Values
  // Set the following&#58;
  //  'Selection of Random New Products'
  //   &#40;MAX_RANDOM_SELECT_NEW&#41; - Sets how many of the most recent new product entries are queried
  //  'New Products Module'
  //   &#40;MAX_DISPLAY_NEW_PRODUCTS&#41; - Sets how many random new products are displayed on screen
  //
  $row = 0;
  $col = 0;
  $pCount = 0;
  $info_box_contents = array&#40;&#41;;
  $found_products = array&#40;&#41;;
  $num_rows = tep_db_num_rows&#40;$new_products_query&#41;;
  if &#40;MAX_DISPLAY_NEW_PRODUCTS > MAX_RANDOM_SELECT_NEW&#41; &#123;
    // don't allow more new products than will be queried
    $max_new_products = MAX_RANDOM_SELECT_NEW;
  &#125; else &#123;
    $max_new_products = MAX_DISPLAY_NEW_PRODUCTS;
  &#125;
  if &#40;$num_rows < $max_new_products&#41; &#123;
          $max_new_products = $num_rows;
  &#125;
//  echo "num_rows&#58; " . $num_rows . " max_new_products " . $max_new_products . "<br>";
  if &#40;$num_rows > 0&#41; &#123;        
    while &#40;$pCount < $max_new_products&#41; &#123;    
      // choose a random row
      $random_product = '';
      $random_row = tep_rand&#40;0, &#40;$num_rows - 1&#41;&#41;;
      tep_db_data_seek&#40;$new_products_query, $random_row&#41;;
      $random_product = tep_db_fetch_array&#40;$new_products_query&#41;;
      // see if found already, if not use else skip
      $found = 0;
      for &#40;$ii=0; $ii < $pCount; $ii++&#41; &#123;
        if &#40;$found_products&#91;$ii&#93; == $random_product&#91;'products_id'&#93;&#41; &#123;
          $found = 1;
          break;
        &#125;
      &#125;
      if &#40;$found == 0&#41; &#123;
        // keep track of found id's
        $found_products&#91;$pCount&#93; += $random_product&#91;'products_id'&#93;;
        $pCount ++;
        // add to display array
        $random_product&#91;'products_name'&#93; = tep_get_products_name&#40;$random_product&#91;'products_id'&#93;&#41;;
        $info_box_contents&#91;$row&#93;&#91;$col&#93; = array&#40;'align' => 'center',
                                           'params' => 'class="smallText" width="33%" valign="top"',
                                           'text' => '<a href="' . tep_href_link&#40;FILENAME_PRODUCT_INFO, 'products_id=' . $random_product&#91;'products_id'&#93;&#41; . '">' . tep_image&#40;DIR_WS_IMAGES . $random_product&#91;'products_image'&#93;, $random_product&#91;'products_name'&#93;, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT&#41; . '</a><br><a href="' . tep_href_link&#40;FILENAME_PRODUCT_INFO, 'products_id=' . $random_product&#91;'products_id'&#93;&#41; . '">' . $random_product&#91;'products_name'&#93; . '</a><br>' . $currencies->display_price&#40;$random_product&#91;'products_price'&#93;, tep_get_tax_rate&#40;$random_product&#91;'products_tax_class_id'&#93;&#41;&#41;&#41;;
        $col ++;
        if &#40;$col > 2&#41; &#123;
          $col = 0;
          $row ++;
        &#125;
      &#125; // found
    &#125; // while pCount
  &#125; // num_rows  
// end random new products

  new contentBox&#40;$info_box_contents&#41;;
?>
<!-- new_products_eof //-->

Intente agregando al codigo ORIGINAL lo que yo crei diferente en el archivo aleatorio......pero algo paso.....que Paliza no resulto

mil, gracias por cualquier ayuda que se me pueda proporcionar.

Saludos a todos
adsoma

Soluciones Web desde US $9.96 mes
E-commerce, foros, chats, blogs, Joomla
nuke, subastas, y mas!
**TODO ILIMITADO!!!**
www.crisolution.com
Completo Perfil Privado Website