$query->registerRuntimeField("store",[
"data_type" => "\Bitrix\Catalog\StoreProductTable",
'reference' => [
'this.ID' => 'ref.PRODUCT_ID'
],
]);
$query->registerRuntimeField("DETAIL_AMOUNT",[
"data_type" => "integer",
"expression" => array("sum(%s)", "store.AMOUNT")
]);
const className = 'class';
const index = 1;
const element = document.querySelector(`.${className}:nth-child(${index + 1})`);
const element = document.querySelectorAll('.' + className)[index];
// или
const element = document.getElementsByClassName(className).item(index);