Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2007
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Creating an XML file using data from an Ecommerce website...

    I am working on an e-commerce website that is well established. The products were manually placed into the database. Is it possible to grab all the product details and place them in an xml and cvs file so I can feed them into other websites?

  • #2
    New Coder
    Join Date
    Aug 2008
    Location
    Addison Tx
    Posts
    20
    Thanks
    6
    Thanked 0 Times in 0 Posts
    I am not sure about making them in to a csv as I have not done that.

    I have a mySql db that stores information from a load of forms (could be existing data also) I grab it all via a sql query and then generate an xml string and send the a specified url using cURL.

    Exp:

    Query
    PHP Code:

    session_start
    ();

    require_once(
    "../../Connections/dbadd.php");
        
        
    $transactionId $_SESSION['form_data']['transactionId'];
        
        
    //Query to select ALL from dbadd db //
        //transactionId as key

        
    $xmlVarSet "SELECT * FROM aib
        LEFT JOIN cd ON aib.transactionId = cd.transactionId 
        LEFT JOIN cp ON aib.transactionId = cp.transactionId 
        LEFT JOIN fd_a ON aib.transactionId = fd_ach.transactionId
        LEFT JOIN fd_c ON aib.transactionId = fd_cc.transactionId 
        LEFT JOIN fd_d ON aib.transactionId = fd_dbt.transactionId
        LEFT JOIN fe ON aib.transactionId = fe.transactionId
        LEFT JOIN rf ON aib.transactionId = rf.transactionId
        LEFT JOIN st ON aib.transactionId = st.transactionId
        LEFT JOIN ct ON aib.transactionId = ct.transactionId
        WHERE aib.transactionId = '$transactionId';"

    Generate the xml string something like this….

    PHP Code:
        include_once("../../gatewayapi/inc_gatewayapi.php"); 
        require_once(
    "../../Connections/dbadd.php");
        require_once(
    "../../db_calls/get_session.php");
        
        function 
    StripSpecChar($val) {
        return (
    preg_replace('/[^a-zA-Z0-9" "-.@]/',''$val));
        }
        
        
    $query = ($xmlVarSet);  
        
    $res mysql_query($query)or die(mysql_error());  
        if(
    $res){  
           while(
    $row mysql_fetch_assoc($res)){  
              foreach(
    $row as $key => $val){  
                 
    $_SESSION['db'][$key] = StripSpecChar($val);            
              }  
           }  
        }

    $xmlString .= "< NewAdd xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation='NewAdd.xsd'>\n";

        
         
    // ****** LOGIN PART ****** 
             
     
    $xmlString .= "<Login>\n";
        
    $xmlString .= "<transactionId>"$_SESSION[‘db’][‘transactionId’] . "</transactionId>\n";
    $xmlString .= "</Login>\n";

        
    // ****** SUBMISSION TYPE ******  
    $xmlString .= "<All>\n";
            
    $xmlString .= "<Corporate>\n";
                
    $xmlString .= "<CpBus>\n";
                    
    $xmlString .= "<agent_id>"$_SESSION['db']['agentId'] ."</agent_id>\n";
                    
    $xmlString .= "<iso_id>"$_SESSION['db']['isoId'] . "</iso_id>\n";
                    
    $xmlString .= "<bb_id>"$_SESSION['db']['bbId'] . "</bb_id>\n";
                    
    $xmlString .= "<cp_legal_name>"$_SESSION['db']['cpLegalName'] . "</cp_legal_name>\n";
                    
    $xmlString .= "<cp_dba_name>"$_SESSION['db']['cpDbaName'] . "</cp_dba_name>\n";
                
    $xmlString .= "</CpBus>\n";
            
    $xmlString .= "</Corporate>\n";
    $xmlString . = "</All>\n";

    $xmlString .= "</NewAdd>\n"
    I then make a connection using cURL and send to what every URL is designated….
    Don’t know if that helps and I am sure that there are easier ways to do it but this is what I have and your question sounded along the same lines.

    Cheers.

  • #3
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by twilight85 View Post
    I am working on an e-commerce website that is well established. The products were manually placed into the database. Is it possible to grab all the product details and place them in an xml and cvs file so I can feed them into other websites?
    for csv you can use:

    http://www.php.net/manual/en/function.fputcsv.php

    along with nine72 suggestion for xml.

    PS: I assume you want csv - comma separated format not cvs - control version system.

    best regards


  •  

    Posting Permissions

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