A
A
Anton2018-02-23 19:20:14
PHP
Anton, 2018-02-23 19:20:14

How to assign a value to a variable?

<?php
if (CModule::IncludeModule("sale"))
{
   $arBasketItems = array();
   $dbBasketItems = CSaleBasket::GetList(
                  array("NAME" => "ASC","ID" => "ASC"),
                  array("FUSER_ID" => CSaleBasket::GetBasketUserID(), 
"LID" => SITE_ID, "ORDER_ID" => "NULL"),
                  false,
                  false,
                  array("ID","MODULE","PRODUCT_ID","QUANTITY","CAN_BUY","PRICE"));
   while ($arItems=$dbBasketItems->Fetch())
   {
      $arItems=CSaleBasket::GetByID($arItems["ID"]);
      $arBasketItems[]=$arItems;   
      $cart_num+=$arItems['QUANTITY'];
      $cart_sum+=$arItems['PRICE']*$arItems['QUANTITY'];
 print_r ($arItems["PRODUCT_ID"].'-');
$rsElement = CIBlockElement::GetList(array(), array('ID' => 
$product_id), false, false, array('ID', 'IBLOCK_SECTION_ID'));
if($arElement = $rsElement->Fetch())
{
   echo $arElement['IBLOCK_SECTION_ID'];
$intElementID = $arItems["PRODUCT_ID"]; // ID предложения
$mxResult = CCatalogSku::GetProductInfo(
$intElementID
);
if (is_array($mxResult))
{

$res = CIBlockElement::GetByID($mxResult['ID']);
if($ar_res = $res->GetNext())
$res = CIBlockSection::GetByID($ar_res['IBLOCK_SECTION_ID']);
if($ar_res = $res->GetNext())
 // echo $ar_res['IBLOCK_SECTION_ID'];
$resSection = CIBlockSection::GetNavChain(false, $ar_res['IBLOCK_SECTION_ID']);
$arSection = $resSection->GetNext() ;
$array_sections = $arSection;
echo ($arSection[ID]."</br>");
}
else
{
$res = CIBlockElement::GetByID($arItems["PRODUCT_ID"]);
if($ar_res = $res->GetNext())
$res = CIBlockSection::GetByID($ar_res['IBLOCK_SECTION_ID']);
if($ar_res = $res->GetNext())
 // echo $ar_res['IBLOCK_SECTION_ID'];
$resSection = CIBlockSection::GetNavChain(false, $ar_res['IBLOCK_SECTION_ID']);
$arSection = $resSection->GetNext() ;
$array_sections = $arSection;
echo  ($arSection[ID]."</br>");}
}
};
}
?>

The code displays the section ID $arSection[ID] by the trade offer ID $mxResult['ID'], if the object is not a trade offer, then we will display the section ID by the product ID $arItems["PRODUCT_ID"]
Everything is displayed fine, although the code is clearly a hack .
At the bottom of the page, i.e. behind all this code, I need to create a variable and assign it either Y or N. I need to assign Y if $arSection[ID] is 109, otherwise N
The difficulty arises from the fact that I use $arSection[ twice in my code ID]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
My joy, 2018-02-23
@t-alexashka

$choice = 'N';
if(isset($arSection[ID]) && $arSection[ID] == '109') {
    $choice = 'Y';
}
echo $choice;

or i misunderstood

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question