M
M
malayamarisha2020-06-22 13:51:47
1C-Bitrix
malayamarisha, 2020-06-22 13:51:47

How to get a link to a product?

Good time sukto!
In the product card, you need to find products with a specific property.
Goods were found, only in $ar_fields['DETAIL_PAGE_URL'] the link to the product looks like this #SITE_DIR#catalog/#SECTION_CODE_PATH#/#ELEMENT_ID#/
Please tell me how to get the correct link to the product?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
malayamarisha, 2020-06-22
@malayamarisha

It turns out that instead of Fetch () it was necessary to use GetNext ()
Strange, in the selection, the field "DETAIL_PAGE_URL" is marked
Total

<?
        $arSelect = Array("ID", "IBLOCK_ID", "NAME", "PREVIEW_PICTURE", "DETAIL_PAGE_URL", "PROPERTY_NABOR");
        $arFilter = Array("IBLOCK_ID"=>$arParams['IBLOCK_ID'], "ACTIVE"=>"Y", "PROPERTY_NABOR"=>$arResult['DISPLAY_PROPERTIES']['NABOR']['VALUE']);
        $res = CIBlockElement::GetList(Array("SORT"=>"ASC"), $arFilter, false, false, $arSelect);
        ?>
        <div class="set_wrapp set_block">
            <div class="title"><?=GetMessage("COLLECTION_TITLE")?></div>
                <ul>
                    <?while($ar_fields = $res->GetNext()):?>
                        <?
                        $img_path = CFile::GetPath($ar_fields["PREVIEW_PICTURE"]);
                                <li class="item">
                                    <div class="item_inner">
                                        <div class="image">
                                            <a href="<?=$ar_fields['DETAIL_PAGE_URL']?>">
                                                <img src="<?=$img_path?>" alt="<?=$ar_fields['NAME']?>" title="<?=$ar_fields['NAME']?>">
                                            </a>
                                        </div>
                                        <div class="item_info">
                                            <div class="item-title">
                                                <a href="<?=$ar_fields['DETAIL_PAGE_URL']?>">
                                                    <span><?=$ar_fields['NAME']?></span>
                                                </a>
                                            </div>
                                        </div>
                                    </div>
                                </li>
                    <?endwhile?>
                </ul>
            </div>
        </div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question