// Import the functions you need from the SDKs you need
import { initializeApp } from 'firebase/app';
import { getFirestore, collection, getDocs } from 'firebase/firestore/lite';
import { getStorage } from "firebase/storage";
import { getDatabase, ref, set, get, child, update, remove, query, onValue } from "firebase/database";
пожоже так
const dbRef = ref(database);
get(child(dbRef, "keeps/sectionlist/")).then((snapshot) => {
if (snapshot.exists()) { console.log(snapshot.val()); } else {
console.log("no data found");
}
}).catch((error) => {
console.log("unsaccessful error " + error);
});
sendToBasket: function()
{
if (!this.canBuy)
{
return;
}
// check recommendation
if (this.product && this.product.id && this.bigData)
{
this.rememberProductRecommendation();
}
this.initBasketUrl();
this.fillBasketProps();
var url = this.basketUrl.split('id=')[0] + 'id=';
var arrid = [];
var basketParams = [];
var idmaintov = this.arParamsCustom.PRODUCT.ID;
arrid.push(this.basketUrl.split('id=')[1]);
basketParams.push(this.basketParams);
// получает количесво и id товара анкера
if($('#ankers'+idmaintov).val() > 0) {
arrid.push($('#ankers'+idmaintov).data('id'));
var ankersq = Object.assign({}, this.basketParams);
ankersq.quantity = $('#ankers'+idmaintov).val();
basketParams.push(ankersq);
}
// получает количесво и id услуги монтаж 1 анкера
if($('#construction'+idmaintov).prop('checked') && $('#ankers'+idmaintov).val() > 0){
arrid.push($('#construction'+idmaintov).data('id'));
var construction = Object.assign({}, this.basketParams);
construction.quantity = $('#ankers'+idmaintov).val();
basketParams.push(construction);
}
for (let i = 0; i < arrid.length; i++){
BX.ajax({
method: 'POST',
dataType: 'json',
url: url + arrid[i] ,
data: basketParams[i],
onsuccess: BX.proxy(this.basketResult, this)
});
}
},
if(!CModule::IncludeModule("iblock")) return;
if (!empty($_POST['tovid'])) {
$arSelect = Array("ID", "NAME", "PROPERTY_MORE_PHOTO", "PROPERTY_PRICE1");
$arFilter = Array("IBLOCK_ID"=>3, "ID"=>$_POST["tovid"], "ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y");
$res = CIBlockElement::GetList(Array(), $arFilter, false, Array("nPageSize"=>50), $arSelect);
while($ob = $res->GetNextElement())
{
$arFields = $ob->GetFields();
//print_r($arFields);
$tovar[]=$arFields;
}
$rsFile = CFile::GetByID($tovar[0]["PROPERTY_MORE_PHOTO_VALUE"]);
$arFile = $rsFile->Fetch();
//print_r($arFile);
$imgsrc="/upload/".$arFile['SUBDIR']."/".$arFile['FILE_NAME'];
$img = "<img alt='Изображение товара' src='".$imgsrc."' style='border:medium;display:inline-block;font-size:14px;font-weight:bold;height:auto;margin-right:20px;max-width:110px;text-decoration:none;text-transform:capitalize;vertical-align:middle' class='CToWUd'>";
}
if($recaptcha_success > 0.5)
{
$arFields = Array(
"AUTHOR" => $_POST["user_name"],
"AUTHOR_EMAIL" => $_POST["user_email"],
"PHONE" => $_POST["user_phone"],
"EMAIL_TO" => $arParams["EMAIL_TO"],
"TEXT" => $_POST["MESSAGE"],
"FILE_NAME" => $_FILES['file']['name'],
"TOV_IMG" => $imgsrc,
"TOV_NAME" => $tovar[0]["NAME"],
"TOV_PRICE" => $tovar[0]["PROPERTY_PRICE1_VALUE"],
"TOV_ID" =>$_POST["tovid"],
"IMG" => $img
);
* $_FROM_FIELD_NAMES = array(DATE_ACTIVE_FROM, DATE_ACTIVE_TO);
* $TO_PROPERTY_NAMES = array(DATE_BEGIN, DATE_END);
* copy_from_fields_to_propertys_values(22, array("DATE_ACTIVE_FROM","DATE_ACTIVE_TO"), array("DATE_BEGIN","DATE_END"));
* */
/* для сео свойств */
function copy_from_fields_to_propertys_values($SECTION_ID, $_FROM_FIELD_NAMES){
if ( CModule::IncludeModule ( "iblock" ) ){
$arOrder = array(
"sort" => "ASC",
);
$arFilter = array(
//"IBLOCK_ID" => $IBLOCK_ID,
"SECTION_ID" => $SECTION_ID
);
foreach ( $_FROM_FIELD_NAMES as $property_name ) {
$_FROM_PROPERTY_NAMES_with_prop[] = 'PROPERTY_' . $property_name;
}
$arSelect = array(
"NAME",
"ID" );
$arSelect = array_merge ( $arSelect,$_FROM_PROPERTY_NAMES_with_prop );
$db_elemens = CIBlockElement::GetList ( $arOrder, $arFilter, false, false, $arSelect );
while ( $arElement = $db_elemens->Fetch () ) {
$PRODUCT_ID = $arElement["ID"];
$el = new CIBlockElement;
$arLoadProductArray = Array(
"IPROPERTY_TEMPLATES" => array(
"ELEMENT_META_TITLE" => $arElement["PROPERTY_UN_TITLE_VALUE"],
"ELEMENT_META_DESCRIPTION" => $arElement["PROPERTY_UN_DESCR_VALUE"],
"ELEMENT_META_KEYWORDS" => $arElement["PROPERTY_UN_KEY_VALUE"],
)
);
$res = $el->Update($PRODUCT_ID, $arLoadProductArray); }
} else {
die( "Модуль iblock не установлен" );
}
}
* $_FROM_FIELD_NAMES = array(DATE_ACTIVE_FROM, DATE_ACTIVE_TO);
* $TO_PROPERTY_NAMES = array(DATE_BEGIN, DATE_END);
* copy_from_fields_to_propertys_values(22, array("DATE_ACTIVE_FROM","DATE_ACTIVE_TO"), array("DATE_BEGIN","DATE_END"));
* */
/* для сео свойств */
function copy_from_fields_to_propertys_values($SECTION_ID, $_FROM_FIELD_NAMES){
if ( CModule::IncludeModule ( "iblock" ) ){
$arOrder = array(
"sort" => "ASC",
);
$arFilter = array(
//"IBLOCK_ID" => $IBLOCK_ID,
"SECTION_ID" => $SECTION_ID
);
foreach ( $_FROM_FIELD_NAMES as $property_name ) {
$_FROM_PROPERTY_NAMES_with_prop[] = 'PROPERTY_' . $property_name;
}
$arSelect = array(
"NAME",
"ID" );
$arSelect = array_merge ( $arSelect,$_FROM_PROPERTY_NAMES_with_prop );
$db_elemens = CIBlockElement::GetList ( $arOrder, $arFilter, false, false, $arSelect );
while ( $arElement = $db_elemens->Fetch () ) {
$PRODUCT_ID = $arElement["ID"];
$el = new CIBlockElement;
$arLoadProductArray = Array(
"IPROPERTY_TEMPLATES" => array(
"ELEMENT_META_TITLE" => $arElement["PROPERTY_UN_TITLE_VALUE"],
"ELEMENT_META_DESCRIPTION" => $arElement["PROPERTY_UN_DESCR_VALUE"],
"ELEMENT_META_KEYWORDS" => $arElement["PROPERTY_UN_KEY_VALUE"],
)
);
$res = $el->Update($PRODUCT_ID, $arLoadProductArray); }
} else {
die( "Модуль iblock не установлен" );
}
}
copy_from_fields_to_propertys_values( 824, array("UN_TITLE","UN_DESCR","UN_KEY"));
/*для торговых предложений*/
function copy_from_fields_to_propertys_values($SECTION_ID){
if ( CModule::IncludeModule ( "iblock" ) ){
$arOrder = array(
"sort" => "ASC",
);
$arFilter = array(
//"IBLOCK_ID" => $IBLOCK_ID,
"SECTION_ID" => $SECTION_ID
);
$arSelect = array(
"NAME",
"ID",
);
$arSelect = array_merge ($arSelect);
$db_elemens = CIBlockElement::GetList ( $arOrder, $arFilter, false, false, $arSelect );
while ( $arElement = $db_elemens->Fetch () ) {
$PRODUCT_ID = $arElement["ID"];
$el = new CIBlockElement;
/*для торговых предложений*/
$arSKU = CCatalogSKU::getOffersList(
$PRODUCT_ID,
0,
array('ACTIVE' => 'Y'),
array('ID', 'NAME'),
array()
);
foreach ($arSKU as $key =>$prod) {
foreach ($prod as $key =>$torgpred) {
$arLoadProductArray = Array("NAME" => $arElement["NAME"]);
$res = $el->Update($torgpred["ID"], $arLoadProductArray);
echo $torgpred["ID"];
}
}
}
} else {
die( "Модуль iblock не установлен" );
}
}
copy_from_fields_to_propertys_values( 839);
copy_from_fields_to_propertys_values( 825);
copy_from_fields_to_propertys_values( 880);
copy_from_fields_to_propertys_values( 824);
copy_from_fields_to_propertys_values( 821);
/* поменял сосотояние в торговых предложения взависимоти от цены*/
$productID = $arResult["ITEM"]["ID"];
$res = CCatalogSKU::getOffersList($productID, 0, array('ACTIVE' => 'Y'), array(""), array(""));
foreach ($res["$productID"] as $key => $tpred){
$rsOffers = CIBlockElement::GetList(
array("sort" => "ASC"), // Свойства, по которым идет сортировка
array('ID' => $tpred["ID"]), // Фильтрация
false,
false,
array("ID", "IBLOCK_ID", "NAME","ACTIVE","PROPERTY_SIZE_IMG_SIGN","PROPERTY_MINIMUM_PRICE") // Свойства, которые нужно получить.
);
$price = GetCatalogProductPrice($tpred["ID"], 1);
while ( $arElement = $rsOffers->Fetch () ) {
$el = new CIBlockElement;
$arLoadProductArray = Array(
"ACTIVE" => "N"
);
if(round($price["PRICE"]) == 1){
echo round($price["PRICE"])."!";
$res = $el->Update($tpred["ID"], $arLoadProductArray);
}
}
}