Answer the question
In order to leave comments, you need to log in
How to get the full path from the categories to the product?
Let's say there is a certain product located at the following address:
- Категория 1
-- Категория 2
--- Товар
Answer the question
In order to leave comments, you need to log in
It's a bad idea to use SECTION_CODE_PATH when generating a URL. If you "rebuild" the directory in the future, then all links will change, which will lead to problems with SEO.
Well, on the topic - you can get a link for a specific element like this:
$iterator = \CIBlockElement::GetList(
[],
[
'ID' => $elementId,
],
false,
false,
[
'DETAIL_PAGE_URL',
]
);
if ($item = $iterator->GetNext()) {
echo $item['DETAIL_PAGE_URL'];
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question