Answer the question
In order to leave comments, you need to log in
How to set the path to the image?
Good afternoon.
I have displayed a block with recommended products on the page of the online store, but it does not pick up the product images, it refers to an empty image.
Tell me, please, how to register the path to the image associated with the product?
The catalog.viewed.products.mail component.
It renders the pix like this:
<? elseif ($arProp['SHOW_MODE'] == 'PICT'): ?>
<tr>
<td>
<p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
color: #a8a8a8; font-size: 14px; margin:0 0 5px;">
<?= htmlspecialcharsex($arProp['NAME']); ?>
</p>
<table cellpadding="0" cellspacing="3">
<tbody>
<tr>
<? foreach ($arProp['VALUES'] as $arOneValue): ?>
<td>
<table cellpadding="0" cellspacing="0" bordercolor="#5d9728" border="2">
<tbody>
<tr>
<td width="26" height="26" bgcolor="#000" style="border: none;
background-image:url('<?=$arOneValue['PICT']['SRC']; ?>');">
</td>
</tr>
</tbody>
</table>
</td>
<? endforeach ?>
</tr>
</tbody>
</table>
</td>
</tr>
<tr><td height="15"></td></tr>
<? endif ?>
<img src="/bitrix/templates/.default/components/bitrix/catalog.viewed.products.mail/template1/images/no_photo.png" style="display: block; margin: auto">
<span class="product-item-image-original" id="bx_3966226736_8943_bba1b7f7802c6bb351319fcd6fe1262e_pict" style="background-image: url('/upload/iblock/907/907c7b5cc9bc8a36888aad9021e607a3.png'); "></span>
Answer the question
In order to leave comments, you need to log in
Then the photo can be pulled out like this.
See in the properties of the infablock what the field with the photo is called, let's say IMAGE
and then
$iblokc = 1; //id инфоблока
$arSelect = [
"ID",
"PROPERTY_IMAGE",
//все поля которые вам нужно могут быть тут
];
$arFilter = ["IBLOCK_ID"=> $iblokc
//остальные параметры фильтра
];
$res = CIBlockElement::GetList(Array(), $arFilter3, false, ['nTopCount' => 1], $arSelect3);
while ($result = $res->Fetch()){
$data[] = $result; //$data - массив со всеми полями которые вы ввели в $arSelect
}
//Затем просто обращается к картинкам так
$data['PROPERTY_IMAGE']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question