Answer the question
In order to leave comments, you need to log in
How to display the cost of goods in the news component?
In the news complex component on the detailed view page, I display the product through the property of the "News" infoblock - binding to the element.
<?if (count($arResult["RELATED_PRODUCT"]) > 0): ?>
<h2>Товары</h2>
<?php endif; ?>
<div class="row section-products-area article-items">
<?foreach($arResult["DISPLAY_PROPERTIES"] as $pid=>$arProperty):?>
<?if($pid =="RELATED_PRODUCT"):?>
<?
$st = 2;
for ($i = 0; $i < ceil(count($arProperty["VALUE"])/$st); $i++)
for ($j = 0; $j < $st; $j++)
{
if (isset($arProperty["VALUE"][(($i*$st)+$j)]))
{
$ar_res = CCatalogProduct::GetByIDEx($arProperty["VALUE"][(($i*$st)+$j)]);
$picture = CFile::ShowImage($ar_res['PREVIEW_PICTURE'], "border=0", "", true);
$tID = $ar_res["ID"];
$intIBlockID = 4;
$mxResult = CCatalogSKU::GetInfoByProductIBlock(
$intIBlockID
);
if (is_array($mxResult))
{
$rsOffers = CIBlockElement::GetList(array("PRICE"=>"ASC"),array('IBLOCK_ID' => $mxResult['IBLOCK_ID'], 'PROPERTY_'.$mxResult['SKU_PROPERTY_ID'] => $tID));
while ($arOffer = $rsOffers->GetNext())
{
$ar_price = GetCatalogProductPrice($id, 1);
}
}
echo '<div class="col-lg-3 col-md-6 col-sm-6 col-xs-12 section-product-item">';
echo '<div class="single-new-product mt-40 category-new-product js-product-item">';
echo '<div class="product-img product-img--large">';
echo '<a href="'.$ar_res["DETAIL_PAGE_URL"].'">';
echo $picture;
echo '</a>';
echo '
<div class="new-product-action">
<a href="'.$ar_res["DETAIL_PAGE_URL"].'" class="js-product-more product-block-more" data-url="'.$ar_res["DETAIL_PAGE_URL"].'">
Подробнее </a>
</div>
</div>
<div class="product-content text-center">
<a href="'.$ar_res["DETAIL_PAGE_URL"].'" title="'.$ar_res["NAME"].'">
<p class="product-name">'.$ar_res["NAME"].'</p>
</a>
<p class="product-opt-price">
<span class="product-opt-price-span">Оптовая скидка</span>
</p>
<div id="price">
<p class="product-price"> '.$ar_price["PRICE"].'</p>
</div>
</div>
</div>
</div>
';
}
}
?>
<?endif?>
<?endforeach?>
</div>
Answer the question
In order to leave comments, you need to log in
but it's emptyvoid in $ar_price["PRICE"] or empty $ar_price array returned?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question