Exemplo n.º 1
0
 static function getAllCategories($langId, $shopId, $parentId = 0, $sp = '', $arr = null)
 {
     if ($arr == null) {
         $arr = array();
     }
     $items = DB::getInstance()->executeS("Select c.id_category, cl.name From " . _DB_PREFIX_ . "category as c Inner Join " . _DB_PREFIX_ . "category_lang as cl On c.id_category = cl.id_category Where c.id_parent = {$parentId} AND cl.id_lang = " . $langId . " AND id_shop = " . $shopId);
     if ($items) {
         foreach ($items as $item) {
             $arr[] = array('id_category' => $item['id_category'], 'name' => $item['name'], 'sp' => $sp);
             $arr = VerticalMegaMenusLibraries::getAllCategories($langId, $shopId, $item['id_category'], $sp . '|- ', $arr);
         }
     }
     return $arr;
 }
 static function getAllCategories($langId, $shopId, $parentId = 0, $sp = '', $arr = null)
 {
     if ($arr == null) {
         $arr = array();
     }
     $sql = "Select DISTINCT \n\t\t\t\t\tc.id_category, \n\t\t\t\t\tcl.name \n\t\t\t\tFrom `" . _DB_PREFIX_ . "category` as c \n\t\t\t\t\tInner Join `" . _DB_PREFIX_ . "category_shop` as cs \n\t\t\t\t\t\tOn (c.id_category = cs.id_category AND cs.id_shop = " . $shopId . ") \n\t\t\t\t\tInner Join " . _DB_PREFIX_ . "category_lang as cl \n\t\t\t\t\t\tOn (c.id_category = cl.id_category AND cl.id_lang = " . $langId . ") \n\t\t\t\tWhere \n\t\t\t\t\tc.active = 1 \n\t\t\t\t\tAND c.id_parent = " . $parentId;
     $items = Db::getInstance()->executeS($sql);
     if ($items) {
         foreach ($items as $item) {
             $arr[] = array('id_category' => $item['id_category'], 'name' => $item['name'], 'sp' => $sp);
             $arr = VerticalMegaMenusLibraries::getAllCategories($langId, $shopId, $item['id_category'], $sp . '|- ', $arr);
         }
     }
     return $arr;
 }
Exemplo n.º 3
0
 public function getCategoryLinkOptions($parentId = 0, $selected = '')
 {
     $langId = Context::getContext()->language->id;
     $shopId = Context::getContext()->shop->id;
     $categoryOptions = '';
     if ($parentId <= 0) {
         $parentId = Configuration::get('PS_HOME_CATEGORY');
     }
     $items = VerticalMegaMenusLibraries::getAllCategories($langId, $shopId, $parentId, '|- ', null);
     if ($items) {
         foreach ($items as $item) {
             $key = 'CAT-' . $item['id_category'];
             if ($key == $selected) {
                 $categoryOptions .= '<option selected="selected" value="' . $key . '">' . $item['sp'] . $item['name'] . '</option>';
             } else {
                 $categoryOptions .= '<option value="' . $key . '">' . $item['sp'] . $item['name'] . '</option>';
             }
         }
     }
     return $categoryOptions;
 }