Jump to content

Edit History

ps8modules

ps8modules


update script

Sample show formated price with tax:

<?php
    @ini_set('display_errors', 'on');
@error_reporting(E_ALL | E_STRICT);

    include('./config/config.inc.php');
    include('./init.php');

    $product_prices = array();

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


    foreach ($getProductPrice as $p){
        $getMaxProductPrice = Db::getInstance()->getRow('SELECT * FROM '._DB_PREFIX_.'product_attribute WHERE id_product = '.$p['id_product'].' ORDER BY price DESC');

        if ($getMaxProductPrice['price'] > 0){
            $max = Product::getPriceStatic($p['id_product'], true, $getMaxProductPrice['id_product_attribute']);
        } else {
            $max = Product::getPriceStatic($p['id_product'], true);
        } 
            
        $product_prices[] = array('id_product' => $p['id_product'], 'min_price' => Tools::displayPrice($p['price']), 'max_price' => Tools::displayPrice($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);

Result:

Screenshot_20210929-221738_Chrome.thumb.jpg.929f7e83f4d335cea3a9ccd28881c15b.jpg

ps8modules

ps8modules

Sample show formated price with tax:

<?php
    @ini_set('display_errors', 'on');
@error_reporting(E_ALL | E_STRICT);

    include('./config/config.inc.php');
    include('./init.php');

    $product_prices = array();

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


    foreach ($getProductPrice as $p){
        $getMaxProductPrice = Db::getInstance()->getRow('SELECT * FROM '._DB_PREFIX_.'product_attribute WHERE id_product = '.$p['id_product'].' ORDER BY price DESC');

        if ($getMaxProductPrice['price'] > 0){
            $max = Product::getPriceStatic($p['id_product'], true, $getMaxProductPrice['id_product_attribute']);
        } else {
            $max = Product::getPriceStatic($p['id_product'], true);
        } 
            
        $product_prices[] = array('id_product' => $p['id_product'], 'min_price' => Tools::displayPrice($p['price']), 'max_price' => Tools::displayPrice($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);

Result:

Screenshot_20210929-221738_Chrome.thumb.jpg.929f7e83f4d335cea3a9ccd28881c15b.jpg

ps8modules

ps8modules

Sample show formated price with tax:

<?php
    include('./config/config.inc.php');
    include('./init.php');

    $product_prices = array();

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


    foreach ($getProductPrice as $p){
        $getMaxProductPrice = Db::getInstance()->getRow('SELECT MAX(price) as max_pice, id_product_attribute FROM '._DB_PREFIX_.'product_attribute WHERE id_product = '.$p['id_product']);
        if ($getMaxProductPrice['price'] > 0){
            $max = Product::getPriceStatic($p['id_product'], true, $p['id_product_attribute']);
        } else {
            $max = Product::getPriceStatic($p['id_product'], true);
        } 
            
        $product_prices[] = array('id_product' => $p['id_product'], 'min_price' => Tools::displayPrice($p['price']), 'max_price' => Tools::displayPrice($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);

Result:

Screenshot_20210929-221738_Chrome.thumb.jpg.929f7e83f4d335cea3a9ccd28881c15b.jpg

ps8modules

ps8modules

Sample show formated price with tax:

<?php
    include('./config/config.inc.php');
    include('./init.php');

    $product_prices = array();

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


    foreach ($getProductPrice as $p){
        $getMaxProductPrice = Db::getInstance()->getRow('SELECT MAX(price) as max_pice, id_product_attribute FROM '._DB_PREFIX_.'product_attribute WHERE id_product = '.$p['id_product']);
        if ($getMaxProductPrice['price'] > 0){
            $max = Product::getPriceStatic($p['id_product'], true, $p['id_product_attribute']);
        } else {
            $max = Product::getPriceStatic($p['id_product'], true);
        } 
            
        $product_prices[] = array('id_product' => $p['id_product'], 'min_price' => Tools::displayPrice($p['price']), 'max_price' => Tools::displayPrice($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);

 

×
×
  • Create New...