Jump to content

xml feed discount price


tozi

Recommended Posts

Hi all, i have this script for xml feed. But i need also total price with discount.

 

Any idea how change this script? :(

I need price with discount here <PRICE_VAT>13590</PRICE_VAT>

Here is the result http://sirer.cz/utils/heureka.php

<?php

require 'dibi.php';

dibi::connect(array(
    'driver' => 'mysqli',
    'host' => '',
    'username' => '',
    'password' => '',
    'database' => '',
    'charset' => 'utf8',
    'lazy' => 'true',
));


error_reporting(E_ALL);
ini_set("display_errors", 1);


//Definice hlavičky XML souboru
header("Content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
?>
<SHOP>
    <?
    // Výpis produktů v XML formátu pro Zboží.cz



    $produkty = dibi::select('*')
        ->from('psb_product')
        ->innerJoin('psb_product_lang')->using('(id_product)')
        ->innerJoin('psb_image')->using('(id_product)')
        ->where('active = %i', 1)
        ->where('cover = %i', 1)
        ->where('id_lang = %i', 2)
        ->where('price > %i', 10)

        ->execute();
    foreach ($produkty as $pro) {

        $cat = dibi::select('id_category_default')
            ->from('psb_product')
            ->where('id_product = %i', $pro['id_product'])
            ->fetchSingle();



        $catname = dibi::select('name')
            ->from('psb_category_lang')
            ->where('id_category = %i', $cat)
            ->fetchSingle();


      /* if($cat==3225)$catname = 'Auto-moto |  Autodoplňky |  Autobaterie';*/
        /* if($cat==4)$catname = 'Elektronika |  Baterie |  Olověné baterie';
        if($cat==5)$catname = 'Auto-moto | Příslušenství pro motocykly | Baterie pro motocykly';
        if($cat==8)$catname = 'Auto-moto | Autodoplňky | Nabíječky a startovací boxy';
        if($cat==9)$catname = 'Auto-moto | Autodoplňky | Nabíječky a startovací boxy';*/




        $desc = str_replace('<h2>', '', $pro['description']);
        $desc = str_replace('</h2>', '', $desc);
        $desc = str_replace('&nbsp', '', $desc);
        $cesta = chunk_split($pro['id_image'], "1", "/"); // vypíše '11.22.33.44.'


        if($pro['id_tax_rules_group']==1){
            $svat = $pro['price'] * 1.21;
        }elseif($pro['id_tax_rules_group']==2){
            $svat = $pro['price'] * 1.15;
        }else{
            $svat = $pro['price'];
        }

        $svat = round($svat);
        ?>
        <SHOPITEM>
            <PRODUCTNAME><![CDATA[<?=$pro['name'];?>]]></PRODUCTNAME>
            <DESCRIPTION><![CDATA[<?=$desc;?>]]></DESCRIPTION>
            <URL>http://www.web.cz/index.php?id_product=<?=$pro['id_product'];?>&controller=product&id_lang=2
            </URL>
            <ITEM_TYPE>new</ITEM_TYPE>

            <CATEGORYTEXT><![CDATA[<?=$catname?>]]></CATEGORYTEXT>
            <IMGURL>http://www.web.cz/img/p/<?=$cesta?><?=$pro['id_image']?>-large_default.jpg</IMGURL>
            <PRICE><?=$pro['price']?></PRICE>
            <DELIVERY_DATE>0</DELIVERY_DATE>

            <?php
            if($pro['id_tax_rules_group']==1){
                echo '<VAT>21</VAT>';
            }elseif($pro['id_tax_rules_group']==2){
                echo '<VAT>15</VAT>';
            }else{
                echo '<VAT>21</VAT>';
            }
            ?>


            <PRICE_VAT><?=$svat?></PRICE_VAT>
            <TOLLFREE>0</TOLLFREE>

        </SHOPITEM>
    <? }?>
</SHOP>
Edited by tozi (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...