opencart 2.3.0.2最新产品无特价

时间:2018-02-23 09:44:14

标签: opencart opencart2.x opencart-module opencart2.3

我想,在最新的模块中只能显示没有特价的产品! 在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;
        }
    }

但它不起作用! 我做错了什么? 任何帮助都会被贬低!

2 个答案:

答案 0 :(得分:0)

修改

catalog\controller\extension\module\latest.php

<强>查找

'sort'  => 'p.date_added',

添加后:

'ignore_special'  => 1,

修改

catalog\model\catalog\product.php

查找(第一场比赛):

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

之前添加:

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";
}

然后清除你的缓存。

答案 1 :(得分:0)

@digicart 我已经在catalog \ 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()的末尾

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