Page 1 of 1

Random de Productos en Home de la tienda

Posted: Fri Feb 17, 2012 11:33 am
by carmonaweb
Hola a todos,

Se me ocurrió utilizar el template ProShop para mi tienda pero me doy cuenta que el home.tpl no tiene modulo de ultimos productos y en lugar tiene lo siguiente:

<div class="middle">
<table class="list">
<?php for ($i = 0; $i < sizeof($products); $i = $i + 4) { ?>
<tr>
<?php for ($j = $i; $j < ($i + 3); $j++) { ?>
<td style="width: 25%;"><?php if (isset($products[$j])) { ?>
<a href="<?php echo $products[$j]['href']; ?>"><img src="<?php echo $products[$j]['thumb']; ?>" title="<?php echo $products[$j]['name']; ?>" alt="<?php echo $products[$j]['name']; ?>" /></a><br />
<a href="<?php echo $products[$j]['href']; ?>"><?php echo $products[$j]['name']; ?></a><br /><br />
<?php if ($display_price) { ?>
<?php if (!$products[$j]['special']) { ?>
<span style="color: #900; font-weight: bold; font-size:17px;"><?php echo $products[$j]['price']; ?></span><br />
<?php } else { ?>
<span style="color: #900; font-weight: bold; font-size:17px; text-decoration: line-through;"><?php echo $products[$j]['price']; ?></span> <span style="color: #F00;"><?php echo $products[$j]['special']; ?></span>
<?php } ?>
<?php } ?>
<br /><a href="<?php echo $products[$j]['href']; ?>"><img src="catalog/view/theme/ProShop/image/viewDetails.png"alt="view details" /></a><br />
<?php } ?>
</td>
<?php } ?>
</tr>
<?php } ?>
</table>
</div>


Lo que necesito es que me muestre los productos aleatoriamente (random) y no lo hace. Siempre me muestra los mismos.

Además modificaron el Home.php de Controller/common por lo siguiente:

<?php
class ControllerCommonHome extends Controller {
public function index() {
$this->language->load('common/home');

$this->document->title = $this->config->get('config_title');
$this->document->description = $this->config->get('config_meta_description');

$this->data['heading_title'] = sprintf($this->language->get('heading_title'), $this->config->get('config_name'));

$this->load->model('setting/store');

$store_info = $this->model_setting_store->getStore($this->config->get('config_store_id'));

if ($store_info) {
$this->data['welcome'] = html_entity_decode($store_info['description']);
} else {
$this->data['welcome'] = '';
}

$this->data['text_latest'] = $this->language->get('text_latest');

$this->load->model('catalog/product');
$this->load->model('catalog/review');
$this->load->model('tool/seo_url');
$this->load->model('tool/image');

$this->data['products'] = array();

foreach ($this->model_catalog_product->getLatestProducts(12) as $result) {
if ($result['image']) {
$image = $result['image'];
} else {
$image = 'no_image.jpg';
}

$rating = $this->model_catalog_review->getAverageRating($result['product_id']);

$special = FALSE;

$discount = $this->model_catalog_product->getProductDiscount($result['product_id']);

if ($discount) {
$price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax')));
} else {
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));

$special = $this->model_catalog_product->getProductSpecial($result['product_id']);

if ($special) {
$special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax')));
}
}

$this->data['products'][] = array(
'name' => $result['name'],
'model' => $result['model'],
'rating' => $rating,
'stars' => sprintf($this->language->get('text_stars'), $rating),
'thumb' => $this->model_tool_image->resize($image, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')),
'price' => $price,
'special' => $special,
'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/product&product_id=' . $result['product_id'])
);
}

if (!$this->config->get('config_customer_price')) {
$this->data['display_price'] = TRUE;
} elseif ($this->customer->isLogged()) {
$this->data['display_price'] = TRUE;
} else {
$this->data['display_price'] = FALSE;
}

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/home.tpl')) {
$this->template = $this->config->get('config_template') . '/template/common/home.tpl';
} else {
$this->template = 'default/template/common/home.tpl';
}

$this->children = array(
'common/header',
'common/footer',
'common/column_left',
'common/column_right'
);

$this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
}
}
?>


Alguien sabrá que debo modificar para que me muestre los productos de forma aleatoria, osea cada vez que entre un usuario a la tienda muestre distintos productos y no siempre los mismos?

Gracias a todos.

Re: Random de Productos en Home de la tienda

Posted: Fri Feb 17, 2012 9:46 pm
by celestial
Si sé, 20 post mas abajo del tuyo (por favor lee primero ese post completo para evitarte confusion):

http://forum.opencart.com/viewtopic.php?f=98&t=53021

Re: Random de Productos en Home de la tienda

Posted: Sat Feb 18, 2012 1:20 am
by carmonaweb
Gracias Celestial pero ya lo intenté con la info de ese post y no funcionó.

Re: Random de Productos en Home de la tienda

Posted: Sat Feb 18, 2012 5:25 am
by celestial
carmonaweb wrote:Gracias Celestial pero ya lo intenté con la info de ese post y no funcionó.
Probastes los vqmod's (los 4) ??? estos http://forum.opencart.com/viewtopic.php?f=131&t=32570

Re: Random de Productos en Home de la tienda

Posted: Sat Feb 18, 2012 11:52 am
by carmonaweb
Asi es pero nada... no funcionó =(

Re: Random de Productos en Home de la tienda

Posted: Sun Feb 19, 2012 7:44 pm
by nulosep
carmonaweb wrote:Asi es pero nada... no funcionó =(
Pues una lastima , yo los utilice y me funcionan de fabula...

Saludos.