Skip to content

Instantly share code, notes, and snippets.

@torunar
Created January 21, 2016 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save torunar/6686c17bd85932203d10 to your computer and use it in GitHub Desktop.
Save torunar/6686c17bd85932203d10 to your computer and use it in GitHub Desktop.
diff --git a/app/functions/fn.catalog.php b/app/functions/fn.catalog.php
index 21beeb2..982e874 100644
--- a/app/functions/fn.catalog.php
+++ b/app/functions/fn.catalog.php
@@ -1474,7 +1474,12 @@ function fn_get_categories($params = array(), $lang_code = CART_LANGUAGE)
}
if (!empty($params['max_nesting_level'])) {
- $condition .= db_quote(" AND ?:categories.level <= ?i", $params['max_nesting_level']);
+ if (!empty($params['parent_category_id'])) {
+ $parent_nesting_level = (int) db_get_field("SELECT level FROM ?:categories WHERE category_id = ?i", $params['parent_category_id']);
+ } else {
+ $parent_nesting_level = 0;
+ }
+ $condition .= db_quote(" AND ?:categories.level <= ?i", $params['max_nesting_level'] + $parent_nesting_level);
}
$limit = $join = $group_by = '';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment