Um beim Megashop Theme eine zufällige Produktsortierung im Featured Product Slider zu erreichen, wird der Code um folgende Zeile ergänzt:
shuffle($categories[$item]['products']);
In tptnprodcarousel.php nach folgender Funktion suchen: public function hookDisplayHome($params)
public function hookDisplayHome($params)
{
$cid = (Configuration::get('TPTNCRSL_SELECTED'));
$menu_item = explode(',', $cid);
$id_lang = (int)$this->context->language->id;
$id_shop = (int)Shop::getContextShopID();
$tptnprod_total = Configuration::get('TPTNCRSL_TOTAL');
$tptnprod_sortby = (Configuration::get('TPTNCRSL_SORTBY') ? 'position' : 'name');
$tptnprod_sortway = (Configuration::get('TPTNCRSL_SORTWAY') ? 'DESC' : 'ASC');
$categories = array();
foreach ($menu_item as $item) {
if (!$item)
continue;
$id = $item;
$category = new Category((int)$id, $id_lang);
if (Validate::isLoadedObject($category)) {
$categories[$item]['id'] = $item;
$categories[$item]['name'] = $category->name;
$categories[$item]['products'] = $category->getProducts($id_lang, 1, $tptnprod_total, $tptnprod_sortby, $tptnprod_sortway);
shuffle($categories[$item]['products']);
}
}
$this->smarty->assign(array(
'categories' => $categories,
'homeSize' => Image::getSize(ImageType::getFormatedName('home'))
));
return $this->display(__FILE__, 'tptnprodcarousel.tpl', $this->getCacheId());
}
Die Stelle, die geändert wird, befindet sich ungefähr in der Mitte der Funktion
$category = new Category((int)$id, $id_lang);
if (Validate::isLoadedObject($category)) {
$categories[$item]['id'] = $item;
$categories[$item]['name'] = $category->name;
$categories[$item]['products'] = $category->getProducts($id_lang, 1, $tptnprod_total, $tptnprod_sortby, $tptnprod_sortway);
shuffle($categories[$item]['products']);
}
