50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
<?php
|
|
|
|
$page = $b->ls_get_key("page");
|
|
if (!$page->get_item_parent()) return;
|
|
|
|
$max_items = 10;
|
|
|
|
$count_search = new Search(array(
|
|
"terms" => array(
|
|
"and" => array(
|
|
"item_parent" => $page->get_item_parent(),
|
|
"item_class" => "Product"
|
|
)
|
|
),
|
|
"limit" => 1
|
|
));
|
|
|
|
$count = $count_search->get_count()->count;
|
|
if (!$count) return;
|
|
|
|
$count = $count - $max_items;
|
|
if ($count < $max_items) $count = $max_items;
|
|
|
|
$search = new Search(array(
|
|
"terms" => array(
|
|
"and" => array(
|
|
"item_parent" => $page->get_item_parent(),
|
|
"item_class" => "Product"
|
|
)
|
|
),
|
|
"limit" => $max_items,
|
|
"offset" => mt_rand(0, $count)
|
|
));
|
|
|
|
$items = $search->collect();
|
|
|
|
?>
|
|
|
|
<?php if(count($items)) { ?>
|
|
<section class="section variants">
|
|
<div class="container js-tabs-wrapper" tabname="catalog_hot">
|
|
<h2 class="variants__heading">Похожие товары</h2>
|
|
<article class="variants__products product-list">
|
|
<?php foreach ($items as $key => $product) {
|
|
$b->template_load("productCategory/product_row.php", array("product" => $product));
|
|
} ?>
|
|
</article>
|
|
</div>
|
|
</section>
|
|
<?php } ?>
|