getEntityDataClass(); if ($table === null) { return []; } $rows = $table::getList([ "select" => ["ID", "ACTIVE", "PREVIEW_TEXT", "ACTIVE_FROM", "DATE_CREATE", "PRODUCT_" => "PRODUCT", "RATING_" => "RATING"], "filter" => ["=USER_ID.VALUE" => $userId], "order" => ["ACTIVE_FROM" => "DESC", "ID" => "DESC"], "limit" => self::LIMIT, ])->fetchAll(); $items = []; foreach ($rows as $row) { $date = $row["ACTIVE_FROM"] ?: $row["DATE_CREATE"]; $items[] = [ "product" => (int)$row["PRODUCT_VALUE"], "rating" => max(0, min(5, (int)$row["RATING_VALUE"])), "text" => trim((string)preg_replace('/\s+/u', " ", strip_tags((string)$row["PREVIEW_TEXT"]))), "date" => $date instanceof \Bitrix\Main\Type\DateTime ? $date->getTimestamp() : 0, "published" => $row["ACTIVE"] === "Y", ]; } $products = Related::summariesById(array_column($items, "product")); foreach ($items as $key => $item) { $items[$key]["name"] = $products[$item["product"]]["name"] ?? ""; $items[$key]["url"] = $products[$item["product"]]["url"] ?? ""; } return $items; } }