首页 文章

opencart 2.3.0.2最新产品无特价

提问于
浏览
1

我想,在最新的模块中只能展示没有特价的产品!在 model/catalog/product.php 我修改了 getLatestProducts() 函数

foreach ($query->rows as $result) {

                $product_data[$result['product_id']] = $this->getProduct($result['product_id']);

        }

foreach ($query->rows as $result) {
$queryCheckSpecial = $this->db->query("SELECT product_id FROM ". DB_PREFIX ."product_special WHERE product_id =".$result['product_id']);
    if (!$queryCheckSpecial->row){
        $product_data[$result['product_id']] = $this->getProduct($result['product_id']);
    }else{
        continue;
        }
    }

但它不起作用!我做错了什么?任何帮助将是apreciated!

3 回答

  • 1

    Edit:

    catalog\controller\extension\module\latest.php
    

    Find:

    'sort'  => 'p.date_added',
    

    Add after:

    'ignore_special'  => 1,
    

    Edit:

    catalog\model\catalog\product.php
    

    Find (第一场比赛):

    if (!empty($data['filter_name']) || !empty($data['filter_tag'])) {
    

    Add before:

    if (!empty($data['ignore_special'])) {
        $sql .= " AND (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) IS NULL";
    }
    

    然后清除你的缓存 .

  • 0

    只需更新:

    这个:

    foreach ($query->rows as $result) {
    $queryCheckSpecial = $this->db->query("SELECT product_id FROM ". DB_PREFIX ."product_special WHERE product_id =".$result['product_id']);
        if (!$queryCheckSpecial->row){
            $product_data[$result['product_id']] = $this->getProduct($result['product_id']);
        }else{
            continue;
            }
        }
    }
    

    用:

    foreach ($query->rows as $result) {
        $product_info = $this->getProduct($result['product_id']);
        if (!$product_info['special']){
            $product_data[$result['product_id']] = 
        }
    }
    

    Also don't forget to clear cache before testing.

  • 0

    @digicart我在目录\ controller \ extension \ module \ latest.php中完成了

    'ignore_special'  => 1,
    

    在目录\ model \ catalog \ product.php中

    if (!empty($data['ignore_special']) &&  empty($data['filter_category_id'])){
    
                $this->log->debug('dsadsa');
    
                $queryCheckSpecial = $this->db->query("SELECT product_id FROM ". DB_PREFIX ."product_special WHERE product_id =".$result['product_id']);
                if (!$queryCheckSpecial->row){
    
                    $product_data[$result['product_id']] = $this->getProduct($result['product_id']);
    
                }else{
                    continue;
    
               }
    

    在getproducts()的最后

    它正在最新的页面上工作!问题是在类别页面中,不知何故忽略特殊字段存在,我不知道为什么!

相关问题