But it is showing if a product does not belong to a category also its status is off
So i need to add product status control with mysql query
can you help edit this category.php file
this page https://market.miuiturkiye.net/allcategory
Code: Select all
<?php
class ControllerExtensionModuleFskcatproducts extends Controller {
public function index() {
$this->document->setTitle("Tüm Kategoriler");
$category_list = array(117,240,166,241,242); // Buraya hangi kategoriler gelecekse onların adlarını yazın.
$products = $this->db->query("SELECT category_id,product_id FROM ".DB_PREFIX."product_to_category WHERE category_id IN(".implode(',',$category_list).") GROUP BY product_id")->rows;
$data['products'] = array();
$this->load->model('tool/image');
$this->load->model('catalog/product');
foreach($products as $product){
$category_name = $this->db->query("SELECT name FROM ".DB_PREFIX."category_description WHERE category_id='".$product['category_id']."' AND language_id='".(int)$this->config->get('config_language_id')."'")->row['name'];
$result = $this->model_catalog_product->getProduct($product['product_id']);
if ($result['image']) {
$image = $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
} else {
$image = $this->model_tool_image->resize('placeholder.png', $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
}
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$price = false;
}
if ((float)$result['special']) {
$special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$special = false;
}
if ($this->config->get('config_tax')) {
$tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price'], $this->session->data['currency']);
} else {
$tax = false;
}
if ($this->config->get('config_review_status')) {
$rating = (int)$result['rating'];
} else {
$rating = false;
}
/* if($result['quantity'] == 0){
$stock_control = "no-stock";
}else{
$stock_control = false;
}
*/
$data['products'][$category_name][] = array(
'product_id' => $result['product_id'],
'stock_control' => $stock_control,
'thumb' => $image,
'name' => $result['name'],
'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,
'rating' => $result['rating'],
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
);
}
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('extension/module/fskcatproduct', $data));
}
}