Results 1 to 10 of 13

Hybrid View

  1. #1
    Join Date
    Sep 2005
    Posts
    29
    Plugin Contributions
    0

    Default Real time XML product feed integration?

    I havea supplier that offers a realtime xml feed of inventory/prices etc... is it possible to integrate this into Zen cart and keep it real time?

  2. #2
    Join Date
    Nov 2005
    Posts
    7
    Plugin Contributions
    0

    Default Re: Real time XML product feed integration?

    Yes it is possible
    <?php

    require('includes/application_top.php');

    Header( 'Content-Type: text/xml' );

    echo '<?xml version="1.0" encoding="ISO-8859-1"?>'.chr(10);
    // Déclaration du catalogue. Il est recommandé d'indiquer correctement la langue et le fuseau horaire GMT.
    echo '<catalogue lang="FR" date="'. date('Y-m-d H:i'). '" GMT="+1" version="2.0">'.chr(10);


    $language_code = 'es';
    $currency_code = 'EUR';

    //on reccupere l'id languade en fonction du code language, donc de la langue du site
    $id_language_qry = 'SELECT languages_id FROM languages WHERE code = "'.$language_code.'"';
    $id_language_res = $db->Execute($id_language_qry);
    $id_language = $id_language_res->fields['languages_id'];

    //on reccupere le taux pour convertir dans la bonne devise
    $currency_rate_qry = 'SELECT value FROM currencies WHERE code = \''.$currency_code.'\'';
    $currency_rate_res = $db->Execute($currency_rate_qry);
    $currency_rate = $currency_rate_res->fields['value'];

    //on reccupere les infos des produits
    /*
    $qry = 'SELECT T_pdt.products_id as refInterne,T_pdt.products_model as modele ,T_pdt.products_model AS name, T_pdt_desc.products_description AS description,T_pdt.products_image AS img, ';
    $qry .= 'T_pdt.products_price AS price , specials.specials_new_products_price as discount_price , manufacturers.manufacturers_name as marque, ';
    $qry .= 'T_cat.categories_name AS cat , products_tax_class_id ';
    $qry .= 'FROM manufacturers, products_description AS T_pdt_desc, categories_description AS T_cat ,products AS T_pdt LEFT JOIN specials ON specials.products_id = T_pdt.products_id ';
    $qry .= 'WHERE T_pdt.master_categories_id = T_cat.categories_id ';
    $qry .= 'AND T_cat.language_id =2 AND T_pdt.products_status = 1 AND T_pdt.products_id = T_pdt_desc.products_id AND T_pdt_desc.language_id =2 AND manufacturers.manufacturers_id = T_pdt.manufacturers_id';


    $qry = '
    SELECT T_pdt.products_id as refInterne,T_pdt.products_model as modele ,manufacturers.manufacturers_name as marque, T_pdt_desc.products_name AS name,
    T_pdt_desc.products_description AS description,T_pdt.products_image AS img, T_pdt.products_price AS price , specials.specials_new_products_price as discount_price , T_cat.categories_name AS cat , products_tax_class_id
    FROM products_description AS T_pdt_desc, categories_description AS T_cat ,(products AS T_pdt
    LEFT JOIN specials ON (specials.products_id = T_pdt.products_id) )
    LEFT JOIN manufacturers ON (manufacturers.manufacturers_id = T_pdt.manufacturers_id)
    WHERE T_pdt.master_categories_id = T_cat.categories_id AND T_cat.language_id =2
    AND T_pdt.products_status = 1 AND T_pdt.products_id = T_pdt_desc.products_id AND T_pdt_desc.language_id =2 ';
    */

    $qry = '
    SELECT T_pdt.products_id as refInterne,T_pdt.products_model as modele ,manufacturers.manufacturers_name as marque,
    T_pdt_desc.products_name AS name , T_pdt_desc.products_description AS description,T_pdt.products_image AS img, T_pdt.products_price AS price , specials.specials_new_products_price as discount_price ,

    T_cat.categories_name AS cat , products_tax_class_id

    FROM products_to_categories , products_description AS T_pdt_desc, categories_description AS T_cat ,(products AS T_pdt
    LEFT JOIN specials ON (specials.products_id = T_pdt.products_id) )
    LEFT JOIN manufacturers ON (manufacturers.manufacturers_id = T_pdt.manufacturers_id)
    WHERE products_to_categories.products_id = T_pdt.products_id AND products_to_categories.categories_id = T_cat.categories_id

    AND T_cat.language_id ='.$id_language.'
    AND T_pdt.products_status = 1 AND T_pdt.products_id = T_pdt_desc.products_id
    AND T_pdt_desc.language_id = '.$id_language.' group by T_pdt.products_id ORDER BY T_pdt.products_id;
    ';
    echo '<!--'.$qry.chr(10).'-->';

    $product_list = $db->Execute($qry);
    $i = 1;
    while(!$product_list->EOF)
    {
    $buffer = '<product num="'.$i++.'">';
    $buffer .= '<offer_id>'.$product_list->fields['refInterne'].'</offer_id>';
    $buffer .= '<model>'.$product_list->fields['modele'].'</model>';
    $buffer .= '<name><![CDATA['.$product_list->fields['name'].']]></name>';
    $buffer .= '<description><![CDATA['.$product_list->fields['description'].']]></description>';
    $buffer .= '<brand><![CDATA['.$product_list->fields['marque'].']]></brand>';
    $buffer .= '<category><![CDATA['.$product_list->fields['cat'].']]></category>';

    //prix
    $_prix = number_format(zen_round($product_list->fields['price'] * $currency_rate, 2), 2 , '.' , '');

    //prix_barre
    if ($new_price = zen_get_products_special_price($product_list->fields['refInterne'])) {
    $_prix_barre = $_prix;
    $_prix = number_format(zen_round($new_price * $currency_rate, 2), 2 , '.' , '');
    }

    $buffer .= '<discount_price>'.$_prix.'</discount_price>';
    $buffer .= '<regular_price>'.$_prix_barre.'</regular_price>';
    $buffer .= '<fp></fp>';
    $buffer .= '<img><![CDATA['.HTTP_SERVER.DIR_WS_CATALOG.DIR_WS_IMAGES.$product_list->fields['img'].']]></img>';
    $buffer .= '<url><![CDATA['.HTTP_SERVER.DIR_WS_CATALOG.'index.php?main_page=product_info&products_id='.$pr oduct_list->fields['refInterne'].'&language='.$language_code.']]></url>';
    $buffer .= '</product>';
    echo $buffer.chr(10);
    flush();
    $product_list->MoveNext();
    }
    echo '</catalogue>';
    flush();

    require(DIR_WS_INCLUDES . 'application_bottom.php');

    ?>
    Test this


    Best regard

    www.satpromo.com

  3. #3
    Join Date
    Nov 2006
    Location
    Edinburgh, Scotland
    Posts
    11
    Plugin Contributions
    0

    Default Re: Real time XML product feed integration?

    Quote Originally Posted by satpromo View Post
    Yes it is possible
    <?php

    require('includes/application_top.php');

    Header( 'Content-Type: text/xml' );

    echo '<?xml version="1.0" encoding="ISO-8859-1"?>'.chr(10);
    // Déclaration du catalogue. Il est recommandé d'indiquer correctement la langue et le fuseau horaire GMT.
    echo '<catalogue lang="FR" date="'. date('Y-m-d H:i'). '" GMT="+1" version="2.0">'.chr(10);


    $language_code = 'es';
    $currency_code = 'EUR';

    //on reccupere l'id languade en fonction du code language, donc de la langue du site
    $id_language_qry = 'SELECT languages_id FROM languages WHERE code = "'.$language_code.'"';
    $id_language_res = $db->Execute($id_language_qry);
    $id_language = $id_language_res->fields['languages_id'];

    //on reccupere le taux pour convertir dans la bonne devise
    $currency_rate_qry = 'SELECT value FROM currencies WHERE code = \''.$currency_code.'\'';
    $currency_rate_res = $db->Execute($currency_rate_qry);
    $currency_rate = $currency_rate_res->fields['value'];

    //on reccupere les infos des produits
    /*
    $qry = 'SELECT T_pdt.products_id as refInterne,T_pdt.products_model as modele ,T_pdt.products_model AS name, T_pdt_desc.products_description AS description,T_pdt.products_image AS img, ';
    $qry .= 'T_pdt.products_price AS price , specials.specials_new_products_price as discount_price , manufacturers.manufacturers_name as marque, ';
    $qry .= 'T_cat.categories_name AS cat , products_tax_class_id ';
    $qry .= 'FROM manufacturers, products_description AS T_pdt_desc, categories_description AS T_cat ,products AS T_pdt LEFT JOIN specials ON specials.products_id = T_pdt.products_id ';
    $qry .= 'WHERE T_pdt.master_categories_id = T_cat.categories_id ';
    $qry .= 'AND T_cat.language_id =2 AND T_pdt.products_status = 1 AND T_pdt.products_id = T_pdt_desc.products_id AND T_pdt_desc.language_id =2 AND manufacturers.manufacturers_id = T_pdt.manufacturers_id';


    $qry = '
    SELECT T_pdt.products_id as refInterne,T_pdt.products_model as modele ,manufacturers.manufacturers_name as marque, T_pdt_desc.products_name AS name,
    T_pdt_desc.products_description AS description,T_pdt.products_image AS img, T_pdt.products_price AS price , specials.specials_new_products_price as discount_price , T_cat.categories_name AS cat , products_tax_class_id
    FROM products_description AS T_pdt_desc, categories_description AS T_cat ,(products AS T_pdt
    LEFT JOIN specials ON (specials.products_id = T_pdt.products_id) )
    LEFT JOIN manufacturers ON (manufacturers.manufacturers_id = T_pdt.manufacturers_id)
    WHERE T_pdt.master_categories_id = T_cat.categories_id AND T_cat.language_id =2
    AND T_pdt.products_status = 1 AND T_pdt.products_id = T_pdt_desc.products_id AND T_pdt_desc.language_id =2 ';
    */

    $qry = '
    SELECT T_pdt.products_id as refInterne,T_pdt.products_model as modele ,manufacturers.manufacturers_name as marque,
    T_pdt_desc.products_name AS name , T_pdt_desc.products_description AS description,T_pdt.products_image AS img, T_pdt.products_price AS price , specials.specials_new_products_price as discount_price ,

    T_cat.categories_name AS cat , products_tax_class_id

    FROM products_to_categories , products_description AS T_pdt_desc, categories_description AS T_cat ,(products AS T_pdt
    LEFT JOIN specials ON (specials.products_id = T_pdt.products_id) )
    LEFT JOIN manufacturers ON (manufacturers.manufacturers_id = T_pdt.manufacturers_id)
    WHERE products_to_categories.products_id = T_pdt.products_id AND products_to_categories.categories_id = T_cat.categories_id

    AND T_cat.language_id ='.$id_language.'
    AND T_pdt.products_status = 1 AND T_pdt.products_id = T_pdt_desc.products_id
    AND T_pdt_desc.language_id = '.$id_language.' group by T_pdt.products_id ORDER BY T_pdt.products_id;
    ';
    echo '<!--'.$qry.chr(10).'-->';

    $product_list = $db->Execute($qry);
    $i = 1;
    while(!$product_list->EOF)
    {
    $buffer = '<product num="'.$i++.'">';
    $buffer .= '<offer_id>'.$product_list->fields['refInterne'].'</offer_id>';
    $buffer .= '<model>'.$product_list->fields['modele'].'</model>';
    $buffer .= '<name><![CDATA['.$product_list->fields['name'].']]></name>';
    $buffer .= '<description><![CDATA['.$product_list->fields['description'].']]></description>';
    $buffer .= '<brand><![CDATA['.$product_list->fields['marque'].']]></brand>';
    $buffer .= '<category><![CDATA['.$product_list->fields['cat'].']]></category>';

    //prix
    $_prix = number_format(zen_round($product_list->fields['price'] * $currency_rate, 2), 2 , '.' , '');

    //prix_barre
    if ($new_price = zen_get_products_special_price($product_list->fields['refInterne'])) {
    $_prix_barre = $_prix;
    $_prix = number_format(zen_round($new_price * $currency_rate, 2), 2 , '.' , '');
    }

    $buffer .= '<discount_price>'.$_prix.'</discount_price>';
    $buffer .= '<regular_price>'.$_prix_barre.'</regular_price>';
    $buffer .= '<fp></fp>';
    $buffer .= '<img><![CDATA['.HTTP_SERVER.DIR_WS_CATALOG.DIR_WS_IMAGES.$product_list->fields['img'].']]></img>';
    $buffer .= '<url><![CDATA['.HTTP_SERVER.DIR_WS_CATALOG.'index.php?main_page=product_info&products_id='.$pr oduct_list->fields['refInterne'].'&language='.$language_code.']]></url>';
    $buffer .= '</product>';
    echo $buffer.chr(10);
    flush();
    $product_list->MoveNext();
    }
    echo '</catalogue>';
    flush();

    require(DIR_WS_INCLUDES . 'application_bottom.php');

    ?>
    Test this


    Best regard

    www.satpromo.com

    Hello there, Can I ask where this code is supposed to go please?

  4. #4
    Join Date
    Feb 2006
    Posts
    656
    Plugin Contributions
    0

    Default Re: Real time XML product feed integration?

    I too would like to try this code. Where does it go, and what xml structure does it work with? How is it implemented? Does it work with any xml file for product feed?

    Thanks,
    I Think, Therefore I Zen. I Zen, Therefore, I AM!
    Personalized Flowers!
    Flowertown Speaking Roses
    using version 1.5.7-06232020

  5. #5
    Join Date
    Feb 2007
    Location
    Leicester UK
    Posts
    219
    Plugin Contributions
    0

    Default Re: Real time XML product feed integration?

    The code appears to be in spanish and gives a parse error whe you run it.

    There is a module available for oscommerce and creloaded but it seems kind of expensive for something thats based on free code. In the next week, time permitting, I'll do some research and attempt to re-write the oscommerce version to work with Zencart.

  6. #6
    Join Date
    Nov 2006
    Location
    Edinburgh, Scotland
    Posts
    11
    Plugin Contributions
    0

    Default Re: Real time XML product feed integration?

    You would be an absoloute legend if you could do that... I posted here months ago and been actively searching for a solution since! You would make alot of people very happy!

 

 

Similar Threads

  1. XML product feed
    By DaMixa in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 13 Sep 2011, 08:34 AM
  2. Replies: 1
    Last Post: 25 Oct 2010, 03:34 PM
  3. Xml Feed
    By jewelrylady in forum All Other Contributions/Addons
    Replies: 3
    Last Post: 8 Jun 2006, 05:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg