Jump to content

Edit History

ps8modules

ps8modules

$product_prices = array();

    $getProductPrice = Db::getInstance()->executeS('SELECT id_product, price FROM '._DB_PREFIX_.'product')

    foreach ($getProductPrice as $p){
        $getMaxProductPrice = Db::getInstance()->getValue('SELECT MAX(price) as max_pice FROM '._DB_PREFIX_.'product_attribute WHERE id_product = '.$p['id_product']);
        if ($getMaxProductPrice > 0){
            $max = ($getMaxProductPrice + $p['price']);
        } else {
            $max = $p['price'];
        } 
            
        $product_prices[] = array('id_product' => $p['id_product'], 'min_price' => $p['price'], 'max_price' => $max);
    }

    foreach ($product_prices as $product){
        echo 'ID product: '.$product['id_product'].' - from '.$product['min_price'].' to '.$product['max_price'].'<br>';
    }

    //print_r($product_prices);

This is a sample without discounts, only with attributes.

ps8modules

ps8modules

$product_prices = array();

    $getProductPrice = Db::getInstance()->executeS('SELECT id_product, price FROM '._DB_PREFIX_.'product')

    foreach ($getProductPrice as $p){
        $getMaxProductPrice = Db::getInstance()->getValue('SELECT MAX(price) as max_pice FROM '._DB_PREFIX_.'product_attribute WHERE id_product = '.$p['id_product']);
        if ($getMaxProductPrice > 0){
            $max = $getMaxProductPrice;
        } else {
            $max = $p['price'];
        } 
            
        $product_prices[] = array('id_product' => $p['id_product'], 'min_price' => $p['price'], 'max_price' => $max);
    }

    foreach ($product_prices as $product){
        echo 'ID product: '.$product['id_product'].' - from '.$product['min_price'].' to '.$product['max_price'].'<br>';
    }

    //print_r($product_prices);

This is a sample without discounts, only with attributes.

×
×
  • Create New...