1

I want, in the latest module to be able to show only the products that don't have special price! in model/catalog/product.php I have modified getLatestProducts() function from

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

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

        }

with

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

but it's not working! What I'm doing wrong? any help will be apreciated!

DigitCart
  • 2,980
  • 2
  • 18
  • 28
Ionut Rusen
  • 17
  • 10

3 Answers3

0

Edit:

catalog\controller\extension\module\latest.php

Find:

'sort'  => 'p.date_added',

Add after:

'ignore_special'  => 1,

Edit:

catalog\model\catalog\product.php

Find (first match):

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

Then clear your caches.

DigitCart
  • 2,980
  • 2
  • 18
  • 28
0

simply update:

this:

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

with:

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 I've done in catalog\controller\extension\module\latest.php

'ignore_special'  => 1,

in catalog\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;

           }

at the end of getproducts()

And it's working on latest page! Problem is that in category page, somehow the ignore special field is present, and i don't know why !

Ionut Rusen
  • 17
  • 10