I would like on the homepage, below newest products, a similar listing, but with random products from all over the shop, from all the categories. Anybody tried to insert somenthing like this? It would be great

Code: Select all
srand ((double) microtime( )*1000000);
$random_number = rand(1,4);
Code: Select all
$random_product_data = array();
// repeat as required
$random_products = $database->getRows("select * from product p left join product_description pd on (p.product_id = pd.product_id) left join image i on (p.image_id = i.image_id) where p.status = '1' and pd.language_id = '" . (int)$language->getId() . "' and p.date_available < now() and p.status = '1' and p.product_id = '" . (int)$random_product_number . "'");
foreach ($random_products as $random_product) {
$random_product_data[] = array(
'name' => $random_product['name'],
'href' => $url->href('product', FALSE, array('product_id' => $random_product['product_id'])),
'thumb' => $image->resize($random_product['filename'], $config->get('config_image_width'), $config->get('config_image_height')),
'price' => $currency->format($tax->calculate($random_product['price'], $random_product['tax_class_id']))
);
}
Code: Select all
$view->set('random_products', $random_product_data);
Code: Select all
$results = $database->getRows("select * from product p left join product_description pd on (p.product_id = pd.product_id) left join image i on (p.image_id = i.image_id) where p.status = '1' and pd.language_id = '" . (int)$language->getId() . "' and p.date_available < now() and p.status = '1' order by p.date_added desc limit 6");
Code: Select all
$results = $database->getRows("select * from product p left join product_description pd on (p.product_id = pd.product_id) left join image i on (p.image_id = i.image_id) where p.status = '1' and pd.language_id = '" . (int)$language->getId() . "' and p.date_available < now() and p.status = '1' order by RAND() desc limit 6");
Users browsing this forum: No registered users and 3 guests