megauser Posted August 15, 2022 Report Share Posted August 15, 2022 Помогите с запросом чтоб сделать фильтр в админке по товарам без фото. Примерно знаю где что добавить, но сам запрос составить не могу Quote Link to post Share on other sites
ps-simpla Posted August 15, 2022 Report Share Posted August 15, 2022 Смотри в сторону фильтра по вариантам (в наличии или нет в наличии) Quote Link to post Share on other sites
Featured Comment alexivchenko Posted August 16, 2022 Featured Comment Report Share Posted August 16, 2022 В 15.08.2022 в 19:00, megauser сказал: Помогите с запросом чтоб сделать фильтр в админке по товарам без фото. Примерно знаю где что добавить, но сам запрос составить не могу в 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> <!-- Фильтры --> Quote Link to post Share on other sites
megauser Posted August 21, 2022 Author Report Share Posted August 21, 2022 В 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> <!-- Фильтры --> Спасибо, я нашёл тогда тему тут на форуме где аналогичное решение Quote Link to post Share on other sites
Recommended Posts
Posted by alexivchenko,
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.