Пример #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 = GroupCategoryLibraries::getAllCategories($langId, $shopId, $item['id_category'], $sp . '- ', $arr);
         }
     }
     return $arr;
 }
Пример #2
0
 public function getCategoryOptions($selected = 0, $parentId = 0)
 {
     $langId = Context::getContext()->language->id;
     $shopId = Context::getContext()->shop->id;
     $categoryOptions = '';
     if ($parentId <= 0) {
         $parentId = Configuration::get('PS_HOME_CATEGORY');
     }
     $items = GroupCategoryLibraries::getAllCategories($langId, $shopId, $parentId, '- ', null);
     if ($items) {
         foreach ($items as $item) {
             if ($item['id_category'] == $selected) {
                 $categoryOptions .= '<option selected="selected" value="' . $item['id_category'] . '">' . $item['sp'] . $item['name'] . '</option>';
             } else {
                 $categoryOptions .= '<option value="' . $item['id_category'] . '">' . $item['sp'] . $item['name'] . '</option>';
             }
         }
     }
     return $categoryOptions;
 }