0

It was working quite fine before, but right now whenever I create a new Product it's not showing up anywhere, not in the category I inserted it in or the latest products. But when I try to update my old products by adding a new price in the special area it is updating. I tried clearing the cache manually but nothing happens. All my products are also enabled.

I also tried looking for answers in google and the closest I found was this Latest Products not updating but the question was asked last 2009 and the answer given does not apply. I am also not familiar with php so... can anyone please help?

Jin
  • 142
  • 1
  • 10

1 Answers1

0

Check step-wise

I am taking category page where the product came opencart2\catalog\controller\product\category.php

$results = $this->model_catalog_product->getProducts($filter_data);

check $results is giving some output or not if not then go to opencart2\catalog\model\catalog\product.php

check line 59 getProducts() function and check $sql is giving output or not

public function getProducts($data = array()) {
      $sql = "SELECT p.product_id, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 
      WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, 
      (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id 
      AND pd2.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' 
      AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) 
      AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) 
      ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, 
      (SELECT price FROM " . DB_PREFIX . "product_special ps 
      WHERE ps.product_id = p.product_id 
      AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' 
      AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) 
      AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) 
      ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special";

only here you can find out your product is coming out from database if not then correct your sql query or include some missing values "most probably it will be date of added product"

OR you said that your old product working fine means there is some date problem check it

StackQA
  • 231
  • 1
  • 13