Example #1
0
function catGetCategoryCompactCList($selectedCategoryID)
{
    $path = catCalculatePathToCategory($selectedCategoryID);
    $res = array();
    $res[] = array("categoryID" => 1, "parent" => null, "name" => ADMIN_CATEGORY_ROOT, "level" => 0);
    $q = db_query("select categoryID, parent, name, products_count, uri from " . CATEGORIES_TABLE . " where parent=1 " . " order by sort_order, name ");
    $c_path = count($path);
    while ($row = db_fetch_row($q)) {
        $row["level"] = 1;
        $res[] = $row;
        if ($c_path > 1) {
            if ($row["categoryID"] == $path[1]["categoryID"]) {
                $arres = _recursiveGetCategoryCompactCList($path, 2);
                $c_arres = count($arres);
                for ($i = 0; $i < $c_arres; $i++) {
                    $res[] = $arres[$i];
                }
            }
        }
    }
    return $res;
}
Example #2
0
 function _exportProducts($f, $rate, $export_product_name, $categories_select)
 {
     if (!count($categories_select)) {
         return 0;
     }
     include_once "core/classes/class.html2text.php";
     include_once "core/classes/class.htmlparser.php";
     fputs($f, "  <offers>\n");
     //товары с нулевым остатком на складе
     if (isset($_POST["yandex_dont_export_negative_stock"])) {
         $clause = " and in_stock>0";
     } else {
         $clause = "";
     }
     //какое описание экспортировать
     if ($_POST["yandex_export_description"] == 1) {
         $dsc = "description";
         $dsc_q = ", " . $dsc;
     } else {
         if ($_POST["yandex_export_description"] == 2) {
             $dsc = "brief_description";
             $dsc_q = ", " . $dsc;
         } else {
             $dsc = "";
             $dsc_q = "";
         }
     }
     $clause .= " and categoryID IN (" . implode(", ", xEscSQL($categories_select)) . ")";
     $sql = '
     SELECT
     productID,
     name,
     Price,
     categoryID,
     default_picture' . $dsc_q . ',
     in_stock,
     uri,
     uri_opt_val
     ' . convert_prices() . '
     FROM ' . PRODUCTS_TABLE . '
     WHERE enabled=1' . $clause;
     $q = db_query($sql);
     $store_url = correct_URL(CONF_FULL_SHOP_URL);
     while ($product = db_fetch_row($q)) {
         $price_row = priceRow($product);
         $url = $store_url . fu_make_url($product);
         fputs($f, " <offer available=\"" . ($product['in_stock'] || !CONF_CHECKSTOCK ? 'true' : 'false') . "\" id=\"" . $product["productID"] . "\">\n");
         fputs($f, "   <url>" . $url . "</url>\n");
         //fputs($f, "   <price>" . roundf($product["Price"] * $rate) . "</price>\n");
         fputs($f, "   <price>" . $price_row['Price_base'] . "</price>\n");
         fputs($f, "   <currencyId>RUR</currencyId>\n");
         fputs($f, "   <categoryId>" . $product["categoryID"] . "</categoryId>\n");
         if ($product["default_picture"] != NULL) {
             $pic_clause = " and photoID=" . (int) $product["default_picture"];
         } else {
             $pic_clause = "";
         }
         $q1 = db_query("select filename, thumbnail from " . PRODUCT_PICTURES . " where productID=" . (int) $product["productID"] . $pic_clause);
         $pic_row = db_fetch_row($q1);
         if ($pic_row) {
             if (strlen($pic_row["filename"]) && file_exists("data/small/" . $pic_row["filename"])) {
                 fputs($f, "   <picture>" . $store_url . "data/small/" . str_replace(' ', '%20', _deleteHTML_Elements($pic_row["filename"])) . "</picture>\n");
             } else {
                 if (strlen($pic_row["thumbnail"]) && file_exists("data/medium/" . $pic_row["thumbnail"])) {
                     fputs($f, "   <picture>" . $store_url . "data/medium/" . str_replace(' ', '%20', _deleteHTML_Elements($pic_row["thumbnail"])) . "</picture>\n");
                 }
             }
         }
         switch ($export_product_name) {
             default:
             case 'only_name':
                 $_NameAddi = '';
                 break;
             case 'path_and_name':
                 $_NameAddi = '';
                 $_t = catCalculatePathToCategory($product['categoryID']);
                 foreach ($_t as $__t) {
                     if ($__t['categoryID'] != 1) {
                         $_NameAddi .= $__t['name'] . ':';
                     }
                 }
                 break;
         }
         $product["name"] = _deleteHTML_Elements($_NameAddi . $product["name"]);
         fputs($f, "   <name>" . $product["name"] . "</name>\n");
         if (strlen($dsc) > 0) {
             $product_dsc = new Html2Text($product[$dsc], 10000);
             $product_dsc = $product_dsc->convert();
             fputs($f, "   <description>" . _deleteHTML_Elements($product_dsc) . "</description>\n");
         } else {
             fputs($f, "   <description></description>\n");
         }
         fputs($f, " </offer>\n");
     }
     fputs($f, "  </offers>\n");
 }
Example #3
0
        }
        if ($searchParamName != null) {
            $callBackParam["name"] = $searchParamName;
        }
        if ($rangePrice != null) {
            $callBackParam["price"] = $rangePrice;
        }
        $count = 0;
        $navigatorHtml = GetNavigatorHtml(_getUrlToNavigate($categoryID), CONF_PRODUCTS_PER_PAGE, 'prdSearchProductByTemplate', $callBackParam, $products, $offset, $count);
        $show_comparison = 0;
        $cc_products = count($products);
        for ($i = 0; $i < $cc_products; $i++) {
            $cat = catGetCategoryById($products[$i]["categoryID"]);
            $products[$i]["allow_products_comparison"] = $cat["allow_products_comparison"];
            if ($products[$i]["allow_products_comparison"] == 1 && $categoryID == $products[$i]["categoryID"]) {
                $show_comparison++;
            }
        }
        if (CONF_PRODUCT_SORT == '1') {
            _sortSetting($smarty, _getUrlToSort($categoryID));
        }
        //calculate a path to the category
        $smarty->assign("product_category_path", catCalculatePathToCategory($categoryID));
        $smarty->assign("search_with_change_category_ability", 1);
        $smarty->assign("show_comparison", $show_comparison);
        $smarty->assign("catalog_navigator", $navigatorHtml);
        $smarty->assign("products_to_show_counter", count($products));
        $smarty->assign("products_to_show", $products);
        $smarty->assign("main_content_template", "category_search_result.tpl");
    }
}
Example #4
0
                        } else {
                            $value = STRING_VALUE_IS_UNDEFINED;
                        }
                    }
                    // $item = array( "name" => $option["name"], "value" => $value );
                    $products[$productIndex][$optionIndex] = $value;
                    $existFlag = true;
                    break;
                }
            }
            if (!$existFlag) {
                $products[$productIndex][$optionIndex] = STRING_VALUE_IS_UNDEFINED;
            }
            $productIndex++;
        }
        $optionIndex++;
    }
    $counta = count($products);
    if ($counta > 0) {
        $smarty->assign("product_category_path", catCalculatePathToCategory($products[0]["categoryID"]));
        $category = catGetCategoryById($products[0]["categoryID"]);
        if ($category) {
            $smarty->assign("category_description", $category["description"]);
        }
    }
    $smarty->assign("definedOptions", $definedOptions);
    $smarty->assign("products", $products);
    $smarty->assign("products_count", $counta);
    $smarty->assign("main_content_template", "comparison_products.tpl");
}
$smarty->assign("compare_value", count($_SESSION["comparison"]));