Hi all,
I am using zero supermarket sidebar on my store.
I want the module to select random products to display. This is what I think should be modified
if ($zsidebarsuperblock['block_type'] == _SBTPRODUCT_)
{
$zsidebarsuperblock['product_options'] = ZSidebarSuperBlock::initProductOptions($zsidebarsuperblock['product_options']);
$products = false;
$limit = (int)$zsidebarsuperblock['product_options']['limit'];
$random = false;
$order_by = $zsidebarsuperblock['product_options']['order_by'];
if ($order_by == 'random')
{
$random = true;
$order_by = null;
}
if ($zsidebarsuperblock['product_filter'] == _SPTFEATURES_)
{
$category = new Category(Context::getContext()->shop->getCategory(), $id_lang);
$products = $category->getProducts($id_lang, 1, $limit, $order_by, 'ASC', false, $random, $limit);
}
elseif ($zsidebarsuperblock['product_filter'] == _SPTNEW_)
$products = Product::getNewProducts($id_lang, 0, $limit);
elseif ($zsidebarsuperblock['product_filter'] == _SPTSPECIAL_)
$products = Product::getPricesDrop($id_lang, 0, $limit);
elseif ($zsidebarsuperblock['product_filter'] == _SPTSELLER_)
$products = ProductSale::getBestSales($id_lang, 0, $limit, 'date_add');
elseif ($zsidebarsuperblock['product_filter'] == _SPTSELECTED_)
$products = $this->getProductByArrayId($id_lang, $zsidebarsuperblock['product_options']['selected_products']);
elseif ($zsidebarsuperblock['product_filter'] == _SPTCATEGORY_)
{
$category = new Category((int)$zsidebarsuperblock['product_options']['selected_category'], $id_lang);
$products = $category->getProducts($id_lang, 1, $limit, $order_by, 'ASC', false, $random, $limit);
if ($products) {
shuffle($products);
array_splice($products, ($nb ? $nb : 10));
}
}
$blocks[] = array(
'title' => $zsidebarsuperblock['title'],
'block_type' => $zsidebarsuperblock['block_type'],
'custom_class' => $zsidebarsuperblock['custom_class'],
'number_column' => $zsidebarsuperblock['product_options']['number_column'],
'products' => $products,
);
}
Can anyone tell me how to modify it to select random products