View Issue Details

IDProjectCategoryView StatusLast Update
0000861OXID eShop (all versions)2. ----- eShop backend (admin) -----public2009-06-09 14:49
Reporterralf_trapp Assigned To 
PriorityhighSeveritycrashReproducibilityalways
Status resolvedResolutionfixed 
Product Version4.1.1 revision 18442 
Fixed in Version4.1.2 revision 18998 
Summary0000861: Remove Service -> ERP Interface from Admin area menu
DescriptionIf Checkbox "Bestelldateien schreiben" is checked and "save" is pressed, it's unchecked next time you call the interrface.
This ERP Interface not works. All functionality is moved to the ERP SOAP module. So please remove this menu item from Admin area.
TagsNo tags attached.
Attached Files
cron_export_orders.php (4,840 bytes)   
#!/usr/bin/php
<?php
/**
 * This Script gets orders from OXID eShop and writes orderfiles. Each order one file called <ordernr>.csv.
 *
 * Lineformat is exactly as described in ERP/CSV documentation, just one difference: Only some fields (which needed)
 * are enclosed by double quotes "
 *
 * Example: Getting SID
 * http://testshops/EE/modules/erp/oxerpcsvexport.php?fnc=OXERPLogin&user=admin&pw=admin&version=2.2.0&shopid=1&langid=0
 *
 * Example: Getting ORDERS
 * http://testshops/EE/modules/erp/oxerpcsvexport.php?fnc=OXERPGetOrders&sid=2b53f75583dea05faf970b83726f6047&sSortFieldName=OXORDERNR&iStart=0&iCount=50
 *
 * Example: Getting ORDERARTICLE
 * http://testshops/EE/modules/erp/oxerpcsvexport.php?fnc=OXERPGetOrderArticle&sid=2b53f75583dea05faf970b83726f6047&id=c4bbb6f12015885300ff047b3a80ea9c&iStart=0&iCount=500
 *
 * @link http://www.oxid-esales.com
 * @package  ERP/CSV
 * @copyright � OXID eSales AG 2003-2009
 * @version 1.0
 *
 */

// URL to Shop
define ('ERPSCVURL', 'http://testshops/EE/modules/erp/oxerpcsvexport.php');

// Import- and Export path
define ('EXPORTPATH', '/htdocs/testshops/EE/export');
define ('IMPORTPATH', '/htdocs/testshops/EE/import');

// Admin user data
define ('ADMINUSER', 'admin');
define ('ADMINPASS', 'admin');

// Maximum orders per Script call and maximum articles per order
define ('MAX_ORDERS_PER_CALL', 1);
define ('MAX_ARTICLES_PER_ORDER', 50000);

// Subshop ID and Language
define ('SHOPID', '1');
define ('LANGID', '0');

// Path to cache file for highest order nr
define ('HIGHESTORDDERNRFILENAME', EXPORTPATH.'/highestordernr.txt');

/**
 * Logs in and gets Session ID (SID)
 *
 * @return string session id
 */
function getSID ()
{

    $sUrl = ERPSCVURL.'?fnc=OXERPLogin&user='.ADMINUSER.'&pw='.ADMINPASS.'&version=2.2.0&shopid='.SHOPID.'&langid='.LANGID;

    if ($fp = fopen ($sUrl, 'r')) {
        $sid = fgets($fp, 2048);
        fclose ($fp);
    }

    return $sid;
}

/**
 * Gets articles (= products) for a specfic order and returns it. Version line included.
 *
 * @param string $sSid       Session ID
 * @param string $sOrderOXID Order ID
 *
 * @return array $aOrders Array of product information
 */
function getOrderArticles ($sSid, $sOrderOXID)
{

    $sUrl = ERPSCVURL.'?fnc=OXERPGetOrderArticle&sid='.$sSid.'&id='.$sOrderOXID.'&iStart=0&iCount='.MAX_ARTICLES_PER_ORDER;

    $aOrders = array();
    if ($fp = fopen ($sUrl, 'r')) {
        while ($aOrders[] = fgetcsv ($fp, 4096, ';', '"') ) {
        }
        fclose ($fp);
    }

    return $aOrders;

}

/**
 * Writes (highest) fetched ordernr
 *
 * @param integer $iOrdernr Order number
 *
 * @return nothing
 */
function writeHighestOrderNr ($iOrdernr)
{

    if ($fp = fopen (HIGHESTORDDERNRFILENAME, 'w')) {
        fputs($fp, $iOrdernr);
    }
    fclose($fp);
}

/**
 * Get highest order number
 *
 * @return integer $iOrderNr ordernumber
 */
function getHighestOrderNr ()
{

    $iOrderNr = 0;

    if (file_exists(HIGHESTORDDERNRFILENAME)) {
        if ($fp = fopen (HIGHESTORDDERNRFILENAME, 'r')) {
            $iOrderNr = fgets ($fp, 16);
            fclose($fp);
        }
    }

    return $iOrderNr;
}


/**
 * Writes all collected data which belongs to one order into one file <ordernr>.csv
 *
 * @param array $aOrder         Array of order information (without version line)
 * @param array $aOrderarticles Array of arrays of products (containing version line)
 *
 * @return integer $iOrdernr Order number of written order. NULL if no success in writing order
 */
function writeOrder ($aOrder, $aOrderarticles)
{

    $iOrdernr = $aOrder[5];
    $filename = EXPORTPATH.'/'.$iOrdernr.'.csv';

    if ($fp = fopen ($filename, 'w')) {

        // Version line:
        fputcsv ($fp, $aOrderarticles[0], ';');
        fputcsv ($fp, $aOrder, ';');

        foreach ($aOrderarticles as $name => $value) {
            if ($value[0] == "R") {
                fputcsv($fp, $value, ';');
            }
        }
        fclose($fp);
    } else {
        $iOrdernr = null;
    }

    return $iOrdernr;

}

/**
 * Writes all orders, beginning from last not written order into files.
 *
 * @param string $sSid Session ID
 *
 * @return nothing
 */
function writeOrders ($sSid)
{

    $iStartordernr = getHighestOrderNr ();

    $sUrl = ERPSCVURL.'?fnc=OXERPGetOrders&sid='.$sSid.'&sSortFieldName=OXORDERNR&iStart='.$iStartordernr.'&iCount='.MAX_ORDERS_PER_CALL;

    if ($fp = fopen ($sUrl, 'r')) {
        while ($aOrder = fgetcsv ($fp, 4096, ';', '"') ) {
            if ($aOrder[0] != "V") {
                $sOrderOXID = $aOrder[1];

                $aOrderArticles = getOrderArticles ($sSid, $sOrderOXID);

                $lastordernr = writeOrder ($aOrder, $aOrderArticles);
            }
        }
        fclose ($fp);

        writeHighestOrderNr ($lastordernr);
    }
}


WriteOrders(GetSID());


cron_export_orders.php (4,840 bytes)   
oxerpcron.php (1,463 bytes)   
#!/usr/local/bin/php -q
<?php
/**
 * This Software is the property of OXID eSales and is protected
 * by copyright law - it is NOT Freeware.
 *
 * Any unauthorized use of this software without a valid license key
 * is a violation of the license agreement and will be prosecuted by
 * civil and criminal law.
 *
 * @link http://www.oxid-esales.com
 * @package ERP
 * @copyright (c) OXID eSales AG 2003-2009
 */

// Modify the "shebang" to whatever it need to be on your server
// or remove it and call the php file directly


// set this to the right path
$sShopPath = "/htdocs/testshops/EE/";


// security check, don't start over http
foreach ($_SERVER as $key => $sValue) {
    if (stristr( $key, "HTTP")) {
        die( "HTTP call not allowed!");
    }
}


if (!function_exists('getShopBasePath')) {
    /**
     * Returns path to main stript files.
     * @return string
     */
    function getShopBasePath()
    {
        global $sShopPath;
        return $sShopPath;
    }
}


// Generic utility method file
require_once getShopBasePath() . 'core/oxfunctions.php';

// Including main ADODB include
require_once getShopBasePath() . 'core/adodblite/adodb.inc.php';

// initializes singleton config class
$myConfig = oxConfig::getInstance();

// create ERP Object using shop's Factory
$oERP = oxNew( "oxerpinterface", "core");

$sMessage = $oERP->doImport("/htdocs/testshops/EE/import/importfile.csv", "admin", "admin", 1, 0);

echo($sMessage . PHP_EOL);
?>
oxerpcron.php (1,463 bytes)   
cron_export_articles.php (1,885 bytes)   
#!/usr/bin/php
<?php
/**
 * This Script gets all products from OXID eShop and writes into one csv file.
 *
 * Lineformat is exactly as described in ERP/CSV documentation
 *
 * Example: Getting SID
 * http://testshops/EE/modules/erp/oxerpcsvexport.php?fnc=OXERPLogin&user=admin&pw=admin&version=2.2.0&shopid=1&langid=0
 *
 * Example: Getting all products (=articles)
 * http://testshops/EE/modules/erp/oxerpcsvexport.php?fnc=OXERPGetArticles&sid=2b53f75583dea05faf970b83726f6047
 *
 * @link http://www.oxid-esales.com
 * @package  ERP/CSV
 * @copyright � OXID eSales AG 2003-2009
 * @version 1.0
 *
 */

// URL to Shop
define ('ERPSCVURL', 'http://testshops/EE/modules/erp/oxerpcsvexport.php');

// Import- and Export path
define ('EXPORTPATH', '/htdocs/testshops/EE/export');
define ('IMPORTPATH', '/htdocs/testshops/EE/import');

// Export filename
define ('EXPORTFILENAME', 'products.csv');

// Admin user data
define ('ADMINUSER', 'admin');
define ('ADMINPASS', 'admin');

// Subshop ID and Language
define ('SHOPID', '1');
define ('LANGID', '0');

/**
 * Logs in and gets Session ID (SID)
 *
 * @return string session id
 */
function getSID ()
{

    $sUrl = ERPSCVURL.'?fnc=OXERPLogin&user='.ADMINUSER.'&pw='.ADMINPASS.'&version=2.2.0&shopid='.SHOPID.'&langid='.LANGID;

    if ($fp = fopen ($sUrl, 'r')) {
        $sid = fgets($fp, 2048);
        fclose ($fp);
    }

    return $sid;
}


/**
 * Writes all products into one file
 *
 * @param string $sSid Session ID
 *
 * @return nothing
 */
function writeArticles ($sSid)
{
    if ($fp_out = fopen (EXPORTPATH.'/'.EXPORTFILENAME, 'w') ) {

        $sUrl = ERPSCVURL.'?fnc=OXERPGetArticles&sid='.$sSid;

        if ($fp_in = fopen ($sUrl, 'r')) {
            while ($line = fgets ($fp_in, 10240) ) {
                fputs($fp_out, $line);
            }
            fclose ($fp_in);
        }
    }
}

writeArticles(GetSID());


cron_export_articles.php (1,885 bytes)   
Theme
BrowserAll
PHP Version5.2.6
Database Version5.0.33

Activities

ralf_trapp

2009-05-05 20:17

reporter   ~0000845

Last edited: 2009-05-13 09:51

- Seems not to work for all fields in that page
- Link to documentation does not work (link to
  - EE: http://www.oxid-esales.com/de/resources/help-faq/manual-eshop-ee-4-0-0-0
  - PE: http://www.oxid-esales.com/de/resources/help-faq/manual-eshop-pe-ce-4-0-0-0

If there is a quick fix (some variable in config.inc.php?), post here.

philipp_grashoff

2009-05-06 10:12

reporter   ~0000850

As the documentation cannot be found in online documentation yet (it's in the PDF delivered with the ERP Module), the information about ERP documentation should be completely changed/deleted, e.g.:
"You can find information about the ERP interface in the PDF's delivered with the ERP module."
"Informationen zur ERP Schnittstelle finden Sie in den PDF's, die mit dem ERP-Modul ausgeliefert wurden"

ralf_trapp

2009-05-08 12:36

reporter   ~0000883

Last edited: 2009-05-08 12:37

Solution: Remove this menu item as this menu is only useful for testing and tests also can be made by scripts (nobody really does automation with manual menu)

ralf_trapp

2009-05-19 15:35

reporter   ~0000936

Last edited: 2009-05-19 15:37

Instead of menu here attached three sample files which do the job manually

ralf_trapp

2009-06-08 16:50

reporter   ~0001031

Last edited: 2009-06-08 16:51

oxerpcron.php in released package probably does not work. see attached file for some example that works.

sarunas_valaskevicius

2009-06-09 14:49

reporter   ~0001037

added examplescripts dir besides documentation