Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function selection($cat = '*', $nb = 3)
- {
- $prevs = $categories = $rows = array();
- if(is_numeric($cat)){
- $cats = array(['id_category'=>$cat]);
- }else{
- $sql = "SELECT l.id_category FROM ps_category_lang l JOIN ps_category c ON l.id_category = c.id_category WHERE l.name LIKE '$cat%' ORDER BY c.position";
- $cats = Db::getInstance()->ExecuteS($sql);
- }
- foreach ($cats as $k => $v) {
- if (in_array($v['id_category'], $prevs)) continue;
- $category = $categories[$k] = new Category($v['id_category'], (int)Context::getContext()->language->id);
- $rows[$k] = $category->getProducts((int)Context::getContext()->language->id, 1, $nb, 'position');
- $prevs[ ] = $v['id_category'];
- if ($rows === false || empty($rows)) return false;
- }
- $this->smarty->assign([
- 'rows' => $rows,
- 'categories' => $categories,
- 'size' => $nb
- ]);
- return $this->display(__FILE__, 'selection.tpl');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement