Answer the question
In order to leave comments, you need to log in
`
How to display url of images of products of a certain category?
[[!pdoResources?
&class=`msProductFile`
&where=`{"parent":0}`
&sortby=`product_id`
&sortdir=`asc`
&tpl=`@CODE: [[+product_id]] - [[+url]]<br>`
]]
Answer the question
In order to leave comments, you need to log in
Here's some crazy stuff I did:
get_id snippet:
$params = ['parents' => '11','tpl' => '@CODE:[ [+id] ],']; // параметры для получения id товаров
$id_list = $modx->runSnippet('pdoResources', $params); // запускаем сниппет и вносим id в переменную
$id_list = str_replace("\n", '', $id_list); // удаляем пробелы
$id_list = explode(",", $id_list); // преобразуем в массив
asort($id_list); // сортировка по значению, по возрастанию
foreach ($id_list as $id_item) {
$params1 = ['product'=>$id_item,'tpl'=>'my.tpl.msGallery'];
$result = $modx->runSnippet('msGallery', $params1);
echo $result;
}
{foreach $files as $file}
<p>{$file['product_id']} - {$file['url']}</p>
{/foreach}
[msGallery] The resource with id = 9 is not instance of msProduct.
18 - /assets/images/products/18/images-(2).jpg
18 - /assets/images/products/18/tes-tpkwmnvcpg-r-dflhzeyg.jpg
19 - /assets/images/products/19/gun.jpg
20 - /assets/images/products/20/den-17-yarost-keksa.jpg
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question