Exemplo n.º 1
0
function add_elements_from_file($filename, $iblock_id, $section_id, $series_name, $series_title_prefix, $price_multiplier, $common_options)
{
    $file = file($filename);
    $e1 = array_map(function ($row2) {
        return explode(';', $row2);
    }, $file);
    $el_count = count($e1);
    for ($i = 1; $i < $el_count; $i++) {
        test_dump($i);
        $row = $e1[$i];
        test_dump($row);
        $BRAND_REF = "itprom";
        $TB_WIDTH = $row[3];
        $TB_HEIGHT = $row[2];
        $TB_DEPTH = $row[4];
        $PRICE_EUR = $row[7];
        $w = intval($TB_WIDTH);
        $h = intval($TB_HEIGHT);
        $d = intval($TB_DEPTH);
        test_dump(array($w, $h, $d));
        $TP_IP_CLASS = "";
        if ($row[1] == "21-30") {
            $TP_IP_CLASS = 164;
        } elseif ($row[1] == "21-32") {
            $TP_IP_CLASS = 165;
        } elseif ($row[1] == "21-33") {
            $TP_IP_CLASS = 166;
        } elseif ($row[1] == "21-35") {
            $TP_IP_CLASS = 167;
        }
        //Раннев сказал везде делать 31
        $TP_IP_CLASS = 168;
        $ARTNUMBER = "arm19" . "-" . $w / 10 . $h / 10 . $d . "_" . $TP_IP_CLASS;
        $NAME = $row[0];
        $MORE_PHOTO = array();
        $MORE_PHOTO_2D = array();
        if ($h > 1100) {
            $DETAIL_PICTURE = CFile::MakeFileArray("images/19inch/shkaf3.jpg");
            $MORE_PHOTO[] = array();
        } else {
            $DETAIL_PICTURE = CFile::MakeFileArray("images/19inch/shkaf1.jpg");
            $MORE_PHOTO[] = array(CFile::MakeFileArray("images/19inch/shkaf2.jpg"));
        }
        $TB_SERIES = "";
        $P = array("ARTNUMBER" => $ARTNUMBER, "BRAND_REF" => $BRAND_REF, "TB_SERIES" => $TB_SERIES, "TB_WIDTH" => $TB_WIDTH, "TB_HEIGHT" => $TB_HEIGHT, "TB_DEPTH" => $TB_DEPTH, "TP_IP_CLASS" => $TP_IP_CLASS, "MORE_PHOTO" => $MORE_PHOTO, "DESCRIPTION_TEXT" => $row[5]);
        $PRICE_EUR = floatval($PRICE_EUR) * $price_multiplier;
        if ($w * $w + $h * $h + $d * $d != 0) {
            test_dump(array($iblock_id, $section_id, $series_title_prefix . " " . $NAME, $PRICE_EUR, $P, $DETAIL_PICTURE));
            add_element($iblock_id, $section_id, $series_title_prefix . " " . $NAME, $PRICE_EUR, $P, $DETAIL_PICTURE);
        } else {
            echo "Не добавлен!<br>";
            echo $w . " " . $h . " " . $d . "<br>";
        }
    }
}
Exemplo n.º 2
0
<?IncludeTemplateLangFile(__FILE__);?>
<?if (isset($GLOBALS["catdets"])):?>
<div class="wrapper"><div class="bottomprods">
    <div class="clearboth"></div>
    <div id="linkedproducts">
        <?test_dump($GLOBALS["catdets"]);?>
        <?$APPLICATION->IncludeComponent(
            "bitrix:sale.recommended.products",
            ".default",
            array(
                "ID" => $GLOBALS["catdets"],
                "MIN_BUYES" => "1",
                "DETAIL_URL" => $arResult["DETAIL_PAGE_URL"],
                "BASKET_URL" => "/personal/basket.php",
                "ACTION_VARIABLE" => "action",
                "PRODUCT_ID_VARIABLE" => "id",
                "ELEMENT_COUNT" => "5",
                "LINE_ELEMENT_COUNT" => "5",
                "PRICE_CODE" => array(
                ),
                "USE_PRICE_COUNT" => "Y",
                "SHOW_PRICE_COUNT" => "1",
                "PRICE_VAT_INCLUDE" => "Y",
                "CACHE_TYPE" => "A",
                "CACHE_TIME" => "3600",
                "CONVERT_CURRENCY" => "Y",
                "CURRENCY_ID" => "RUB",
                "COMPONENT_TEMPLATE" => ".default",
                "IBLOCK_TYPE" => "catalog",
                "IBLOCK_ID" => "4",
                "CODE" => "",
Exemplo n.º 3
0
<?php

require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/header.php";
$actual_link = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
test_dump($actual_link);
test_dump($_GET);
Exemplo n.º 4
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (!empty($arResult['ERROR'])) {
    echo $arResult['ERROR'];
    return false;
}
test_dump($arResult);
//$APPLICATION->SetPageProperty("title", $arResult["ELEMENT"]["PROPERTIES"]["TITLE"]["VALUE"]);
$GLOBALS['APPLICATION']->SetAdditionalCSS('/bitrix/js/highloadblock/css/highloadblock.css');
$listUrl = str_replace('#BLOCK_ID#', intval($arParams['BLOCK_ID']), $arParams['LIST_URL']);
?>
<div class="myContent" style="padding-bottom: 0;">
<a href="<?php 
echo htmlspecialcharsbx($listUrl);
?>
"><?php 
echo GetMessage('HLBLOCK_ROW_VIEW_BACK_TO_LIST');
?>
</a>
    <?php 
$myRow = $arResult['row'];
$GLOBALS['APPLICATION']->SetTitle(GetMessage("HLBLOCK_ROW_VIEW_BRAND_HEAD", array("#BRAND_NAME#" => $myRow["UF_NAME"])));
?>
	  <h1>fsdf<?php 
echo GetMessage("HLBLOCK_ROW_VIEW_BRAND_HEAD", array("#BRAND_NAME#" => $myRow["UF_NAME"]));
?>
</h1>
      <div class="brand_photo_holder"><img src="<?php 
Exemplo n.º 5
0
function add_elements_from_file($filename, $iblock_id, $section_id, $series_name, $series_title_prefix, $price_multiplier)
{
    $image_files = scan_Dir("images/tb-images");
    chdir("..");
    test_dump($image_files);
    //Получить мощность и IP
    $power_file = file("power_and_ip.csv");
    $power_and_ip = array_map(function ($row1) {
        return explode(';', $row1);
    }, $power_file);
    test_dump($power_file);
    $file = file($filename);
    $e1 = array_map(function ($row2) {
        return explode(';', $row2);
    }, $file);
    $el_count = count($e1);
    test_dump($el_count);
    for ($i = 1; $i < $el_count; $i++) {
        test_dump($i);
        $row = $e1[$i];
        for ($j = 5; $j <= 15; $j++) {
            if ($row[$j] != "") {
                $row[$j] = "Y";
            }
        }
        //вместо цен ставим "Есть" или "Нет" как бы
        $row[0] = "НЕ НУЖНО";
        $row[3] = "НЕ НУЖНО";
        $row[16] = "НЕ НУЖНО";
        $row[17] = "НЕ НУЖНО";
        unset($row[19]);
        unset($row[20]);
        unset($row[21]);
        unset($row[22]);
        $BRAND_REF = "itprom";
        $TB_SERIES = "";
        if ($series_name == "TL") {
            $TB_SERIES = 123;
        } elseif ($series_name == "T") {
            $TB_SERIES = 124;
        } elseif ($series_name == "VT") {
            $TB_SERIES = 125;
        } elseif ($series_name == "IBL") {
            $TB_SERIES = 158;
        } elseif ($series_name == "IB") {
            $TB_SERIES = 159;
        } elseif ($series_name == "IBV") {
            $TB_SERIES = 160;
        }
        $r = explode("+", $row[2]);
        $option = "NONE";
        if (count($r) == 2) {
            $option = $r[1];
            $TB_PANELS = "128";
            if (substr_count($option, "оков") > 0) {
                $TB_OPTION = "150";
            } elseif (substr_count($option, "лухая") > 0) {
                $TB_OPTION = "151";
            } elseif (substr_count($option, "анель") > 0) {
                $TB_OPTION = "152";
            }
        }
        $size = explode("x", $r[0]);
        if (count($size) == 3) {
            echo "<p>({$size['0']}, {$size['1']}, {$size['2']}) + {$option} <br /></p>";
            $TB_WIDTH = $size[0];
            $TB_HEIGHT = $size[1];
            $TB_DEPTH = $size[2];
        } else {
            echo "WRONG SIZE!";
        }
        if ($series_name == "VT" || $series_name == "IBV") {
            $PRICE_EUR = str_replace(" ", "", str_replace("€", "", $row[18 + 1]));
        } else {
            $PRICE_EUR = str_replace(" ", "", str_replace("€", "", $row[18]));
        }
        echo "Цена ({$PRICE_EUR}) евро<br />\n";
        $w = intval($TB_WIDTH);
        $h = intval($TB_HEIGHT);
        $d = intval($TB_DEPTH);
        $power_ip_count = count($power_and_ip);
        $count = 0;
        $p_row_id = -1;
        for ($k = 0; $k < $power_ip_count; $k++) {
            $p_row = $power_and_ip[$k];
            if ($p_row[1] == $w && $p_row[2] == $h && $p_row[3] == $d) {
                $count++;
                $p_row_id = $k;
            }
        }
        $TP_HEAT_POWER = "";
        $TP_IP_CLASS = "";
        //$series_from_list = explode("-", $power_and_ip[$p_row_id][0])[0];
        //test_dump($series_from_list);
        //echo "Series: " . $series_name . " = " . $series_from_list . "<br>";
        if ($count == 1) {
            $TP_HEAT_POWER = $power_and_ip[$p_row_id][4];
            $TP_IP_CLASS = $power_and_ip[$p_row_id][6];
        }
        if ($series_name == "T") {
            $TP_IP_CLASS = "157";
        } elseif ($series_name == "VT") {
            $TP_IP_CLASS = "156";
        }
        if ($count == 1) {
            echo "count: " . $count . "<br>";
        } else {
            echo "<h1>count: " . $count . "</h1><br>";
        }
        $NAME = $series_name . "-" . $w / 10 . $h / 10 . $d;
        //$image_prefix = $w . "-" . $h . "-" . $d . " " . $series_name . " ";
        $image_prefix = $w . "-" . $h . "-" . $d . " ";
        $image_count = count($image_files);
        $MORE_PHOTO = array();
        $MORE_PHOTO_2D = array();
        $DETAIL_PICTURE = "";
        //Если изображение ищется для серий IB* нужно искать для соответствующих серий TL, T, VT
        $series_name_img = $series_name;
        if ($series_name == "IBL") {
            $series_name_img = "TL";
        } elseif ($series_name == "IBV") {
            $series_name_img = "VT";
        } elseif ($series_name == "IB") {
            $series_name_img = "T";
        }
        for ($k = 0; $k < $image_count; $k++) {
            $image_path = $image_files[$k];
            $image_name = basename($image_path);
            //echo "Image name " . $image_name . "<br>";
            if (0 === strpos($image_name, $image_prefix) && 0 != strpos($image_path, " " . $series_name_img . " ")) {
                echo "FOUND IMAGE! " . $image_path . "<br>";
                if (strpos($image_name, "3D") != false) {
                    $MORE_PHOTO[] = CFile::MakeFileArray($image_path);
                } else {
                    $MORE_PHOTO_2D[] = CFile::MakeFileArray($image_path);
                }
            }
        }
        if (count($MORE_PHOTO) > 0) {
            $DETAIL_PICTURE = $MORE_PHOTO[0];
            unset($MORE_PHOTO[0]);
        }
        foreach ($MORE_PHOTO_2D as $PHOTO) {
            $MORE_PHOTO[] = $PHOTO;
        }
        //test_dump($MORE_PHOTO);
        if ($TP_HEAT_POWER != "") {
            $NAME = $NAME . "-" . $TP_HEAT_POWER;
        }
        echo $NAME . "<br>";
        if ($series_name != "VT" || $series_name != "IBV") {
            $P = array("ARTNUMBER" => $NAME, "BRAND_REF" => $BRAND_REF, "TB_SERIES" => $TB_SERIES, "TB_WIDTH" => $TB_WIDTH, "TB_HEIGHT" => $TB_HEIGHT, "TB_DEPTH" => $TB_DEPTH, "TB_PANELS" => $TB_PANELS, "TB_DBK_COOL" => emptyOrValue($row[5], 130), "TB_DBK_HEAT" => emptyOrValue($row[6], 132), "TB_RESH" => emptyOrValue($row[8], 134), "TB_FAN" => emptyOrValue($row[9], 136), "TB_FAN_RESH" => emptyOrValue($row[10], 138), "TB_DIN_ROZ" => emptyOrValue($row[11], 140), "TB_DIN_AUTO" => emptyOrValue($row[12], 1142), "TB_KLEMM" => emptyOrValue($row[13], 144), "TB_DIN_METIZ" => emptyOrValue($row[14], 146), "TB_UTEPLITEL" => emptyOrValue($row[15], 148), "TB_OPTION" => $TB_OPTION, "TP_IP_CLASS" => $TP_IP_CLASS, "TP_HEAT_POWER" => $TP_HEAT_POWER, "MORE_PHOTO" => $MORE_PHOTO);
        } else {
            $P = array("ARTNUMBER" => $NAME, "BRAND_REF" => $BRAND_REF, "TB_SERIES" => $TB_SERIES, "TB_WIDTH" => $TB_WIDTH, "TB_HEIGHT" => $TB_HEIGHT, "TB_DEPTH" => $TB_DEPTH, "TB_PANELS" => $TB_PANELS, "TB_DBK_COOL" => emptyOrValue($row[5], 130), "TB_DBK_HEAT" => emptyOrValue($row[6], 132), "TB_RESH" => emptyOrValue($row[8], 134), "TB_FAN" => emptyOrValue($row[9 + 1], 136), "TB_FAN_RESH" => emptyOrValue($row[10 + 1], 138), "TB_DIN_ROZ" => emptyOrValue($row[11 + 1], 140), "TB_DIN_AUTO" => emptyOrValue($row[12 + 1], 1142), "TB_KLEMM" => emptyOrValue($row[13 + 1], 144), "TB_DIN_METIZ" => emptyOrValue($row[14 + 1], 146), "TB_UTEPLITEL" => emptyOrValue($row[15 + 1], 148), "TB_OPTION" => $TB_OPTION, "TP_IP_CLASS" => $TP_IP_CLASS, "TP_HEAT_POWER" => $TP_HEAT_POWER, "MORE_PHOTO" => $MORE_PHOTO);
        }
        $PRICE_EUR = floatval($PRICE_EUR) * $price_multiplier;
        if ($w * $w + $h * $h + $d * $d != 0) {
            add_element($iblock_id, $section_id, $series_title_prefix . " " . $NAME, $PRICE_EUR, $P, $DETAIL_PICTURE);
        } else {
            echo "Не добавлен!<br>";
            echo $w . " " . $h . " " . $d . "<br>";
        }
    }
}