View Issue Details

IDProjectCategoryView StatusLast Update
0002024OXID eShop (all versions)4.05. Performancepublic2012-12-10 13:29
Reportermanuel Assigned To 
PriorityhighSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version4.4.0 revision 28699 
Fixed in Version4.4.2 revision 29492 
Summary0002024: System runs in time out when creating huge amount of vouchers
DescriptionWe have a bug/performance problem, when we want to create voucher codes for flyers (320.000 pieces). Since the amount of 40.000 pieces the system runs in time out. Our thoughts are the unused an commented codes in admin/voucherseries_main.php:

        $oNewVoucher = oxNew( "oxvoucher" );

        //$aVoucherParams = $oNewVoucher->ConvertNameArray2Idx($aVoucherParams);

 

        // first we update already existing and not used vouchers

 

        $oExistingVoucherList = $oVoucherSerie->getVoucherList();

        // prepare voucher params

        foreach ($oExistingVoucherList as $oVoucher) {

            $oVoucher->assign($aVoucherParams);

            $oVoucher->save();

        }

 

You can see, that the script makes an assign on each Voucher with an empty Argument, cause it is commented some lines before. Also the Code for inserting a new Voucher code hasn’t good performance:

        for ($i = 0; $i < $dVoucherAmount; $i++) {

            $oNewVoucher->assign($aVoucherParams);

            $oNewVoucher->oxvouchers__oxvoucherserieid = new oxField($oVoucherSerie->oxvoucherseries__oxid->value);

            $oNewVoucher->oxvouchers__oxvouchernr = new oxField(oxConfig::getParameter("voucherNr"));

            if (oxConfig::getParameter("randomVoucherNr"))

                $oNewVoucher->oxvouchers__oxvouchernr = new oxField(uniqid($oNewVoucher->oxvouchers__oxvouchernr->value));

            $oNewVoucher->save();

            $oNewVoucher = oxNew( "oxvoucher" );

        }

 

We think, that it would be a faster, if you create a oxvoucher object before the for-loop and make clones of the object for inserting. But the fastes way to insert so many vouchers is to make SQL inserts instead of creating an oxvoucher object for each voucher, eg.:

 

            $sSql = 'INSERT INTO oxvouchers (`oxdateused`, `oxvouchernr`, `oxvoucherserieid`, `oxdiscount`, `oxid`) VALUES ("0000-00-00", "'.$sVoucherCode.'", "'.$aVoucherConfig['OXID'].'", "'.$aVoucherConfig['OXDISCOUNT'].'", "'.md5(uniqid($sVoucherCode)).'")';

 

We have tested it with SQL Statements directly and the time for 50.000 pieces on our Webserver takes round about 30 secs. If we use the implementation of OXID and adding vouchers to a new Voucherseries, we got a execution time from 12+ minutes.

 

Best regards
TagsPerformance
Theme
BrowserAll
PHP Versionany
Database Versionany

Activities

arvydas_vapsva

2010-08-18 09:42

reporter   ~0003397

Fixed by implementing generator/exporter ticker, similar to product export. Ticker should remove any limits, you will only have to wait until it finishes generation/export of data you requested.

Some details:
 - VoucherSerie_Main saves voucher serie configuration;
 - VoucherSerie_Export exports vouchers (exports 1000 vouchers per tick - VoucherSerie_Export::$iExportPerTick = 1000);
 - VoucherSerie_Generate generates user defined vouchers (generates 100 vouchers per tick - VoucherSerie_Generate::$iExportPerTick = 100).

birute_meilutyte

2010-08-18 16:05

reporter   ~0003400

now, after new coupon is created, it is not selected by default and user must search for it in whole vouchers list.