Exemplo n.º 1
0
    $_tt = '';
    foreach ($_t as $_key) {
        $_SESSION['checkedCategories'][$_key] = 1;
        $_SESSION['selectedProductsIncSub'][$_key] = $ProductCategories[$_key]['products_count'];
        $Products = prdGetProductByCategory(array('categoryID' => $_key, 'fullFlag' => false), $_tT);
        $c = count($Products);
        for ($_tt = 0; $_tt < $c; $_tt++) {
            if ($Products[$_tt]['enabled']) {
                $_SESSION['selectedProducts'][$_key][$Products[$_tt]['productID']] = 1;
            }
        }
    }
}
if ($flagUpdateSubs) {
    $_cID =& $flagUpdateSubs;
    $_SubC = catGetSubCategories($_cID);
    $c = count($_SubC);
    for ($i = 0; $i < $c; $i++) {
        $_SESSION['checkedCategories'][$_SubC[$i]] = $_SESSION['checkedCategories'][$_cID];
        $_SESSION['selectedProductsIncSub'][$_SubC[$i]] = $_SESSION['checkedCategories'][$_cID] ? isset($ProductCategories[$_SubC[$i]]['products_count']) ? $ProductCategories[$_SubC[$i]]['products_count'] : 0 : 0;
        if (!$_SESSION['checkedCategories'][$_SubC[$i]]) {
            $_SESSION['selectedProducts'][$_SubC[$i]] = array();
        } else {
            $Products = prdGetProductByCategory(array('categoryID' => $_SubC[$i], 'fullFlag' => false), $_t);
            $_c = count($Products);
            for ($_t = 0; $_t < $_c; $_t++) {
                if ($Products[$_t]['enabled']) {
                    $_SESSION['selectedProducts'][$_SubC[$i]][$Products[$_t]['productID']] = 1;
                }
            }
        }
Exemplo n.º 2
0
function catGetSubCategories($categoryID)
{
    $q = db_query("select categoryID from " . CATEGORIES_TABLE . " where parent=" . (int) $categoryID);
    $r = array();
    while ($row = db_fetch_row($q)) {
        $a = catGetSubCategories($row[0]);
        $c_a = count($a);
        for ($i = 0; $i < $c_a; $i++) {
            $r[] = $a[$i];
        }
        $r[] = $row[0];
    }
    return $r;
}
Exemplo n.º 3
0
function _getConditionWithCategoryConjWithSubCategories($condition, $categoryID)
{
    //fetch products from current category and all its subcategories
    $new_condition = "";
    $tempcond = "";
    $categoryID_Array = catGetSubCategories($categoryID);
    $categoryID_Array[] = (int) $categoryID;
    foreach ($categoryID_Array as $catID) {
        if ($new_condition != "") {
            $new_condition .= " OR ";
        }
        $new_condition .= _getConditionWithCategoryConj($tempcond, $catID);
    }
    if ($condition == "") {
        return $new_condition;
    } else {
        return $condition . " AND (" . $new_condition . ")";
    }
}