O
O
Oleg Olegovich2022-04-13 14:46:18
MODX
Oleg Olegovich, 2022-04-13 14:46:18

How to output the number of identical product brand names in a category?

Here is such a thing. 6256b7e1a272b078895860.png

The brand name is given in the tv field.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Tarasov, 2022-04-13
@oregos

1. Display all brands using pdoResources
2. In the chunk for each brand, call a custom snippet, passing as a parameter the name of the brand (if it is just text set in TV), which counts the number, something like this:

<p><span><a href="">[  ]</a></span></p>

Custom snippet:
<?php
$c = $modx->newQuery('modTemplateVarResource');
$c->leftJoin('modResource', 'Resource', array(
    'Resource.id = modTemplateVarResource.contentid'
));
$c->where(array(
    'modTemplateVarResource.tmplvarid' => XX, //XX - ID вашего TV
    'modTemplateVarResource.value' => $value
));
return $modx->getCount('modTemplateVarResource', $c);
return $total;

O
Oleg Olegovich, 2022-04-13
@oregos

I got rid of the repetition of brands through js.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question