Jump to content

Фильтр товаров "без фото" в админ панели


Recommended Posts

Помогите с запросом чтоб сделать фильтр в админке по товарам без фото. Примерно знаю где что добавить, но сам запрос составить не могу

Link to post
Share on other sites
В 16.08.2022 в 20:40, alexivchenko сказал:

в api/Products.php


public function get_products($filter = array()) {
..
$has_images_filter = '';
..
if(isset($filter['has_images'])) {
	$has_images_filter = $this->db->placehold('AND (SELECT count(*)>0 FROM __images pi WHERE pi.product_id=p.id LIMIT 1) = ?', intval($filter['has_images']));
}
..
$has_images_filter
..
}

public function count_products($filter = array()) {
..
$has_images_filter = '';
..
if(isset($filter['has_images'])) {
	$has_images_filter = $this->db->placehold('AND (SELECT count(*)>0 FROM __images pi WHERE pi.product_id=p.id LIMIT 1) = ?', intval($filter['has_images']));
}
..
$has_images_filter
..
}

в simpla/ProductsAdmin.php


if($f = $this->request->get('filter', 'string')) {
..
elseif($f == 'without_images') {
	$filter['has_images'] = 0;
}
}

в simpla/design/html/products.tpl 


<!-- Фильтры -->
<ul>
..
<li {if $filter=='without_images'}class="selected"{/if}>
	<a href="{url keyword=null brand_id=null category_id=null page=null limit=null filter='without_images'}">Без изображений</a>
</li>
</ul>
<!-- Фильтры -->

 

Спасибо, я нашёл тогда тему тут на форуме где аналогичное решение

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...