• 14-01-2020, 10:07:55
    #1
    Arkadaşlar elimde bir xml var ama ilk kez ürün çekerken yüksek miktarda ürün olduğu için time out oluyor bende 50 şer 50 şer çekeyim istiyorum ürünleri xml kodunu aşağı ekleyeceğim
    bunu 50 şer 50 şer çekebilecek bir kod ekleye bilecek bir arkadaş varsa çok sevinirim
    teşekkürler


    <?php

    ob_start();

    date_default_timezone_set('Europe/Istanbul');

    error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED);

    $db = mysql_connect(' ');

    $sl = mysql_select_db(' ');

    mysql_query("SET NAMES 'utf8'");

    mysql_query("SET CHARACTER SET utf8");

    mysql_query("SET COLLATION_CONNECTION = 'utf8_bin'");


    $xml = " ";
    $xmlData = simplexml_load_file($xml,'SimpleXMLElement',LIBXML _NOCDATA);
    $x =0;
    //print_r($xmlData);

    foreach($xmlData->product AS $key =>$val){$x++;
    $UrunAdi = $val->name;
    $UrunKodu = $val->barcode;
    $stok = $val->stock;
    $urunImg = $val->images;
    $categoryPath = $val->category_path;
    $fiyat = number_format(($val->price_list_campaign * (1.08)),2,'.','') ;
    $UrunAciklama = $val->detail;
    $categoryExp = explode('>',$categoryPath);
    echo $fiyat.' -- ';
    // kategori ekletme başladı
    $a = 0;
    $kategoriAdi = $categoryExp[0];
    $categorySql = "SELECT category_id,name FROM oc_category_description WHERE name = '$kategoriAdi' ";
    if(mysql_num_rows(mysql_query($categorySql)) > 0){
    $categoryPrint = mysql_fetch_object(mysql_query($categorySql));
    $categoryID = $categoryPrint->category_id;
    }else{
    $query = mysql_query("INSERT INTO `oc_category`
    (`column`,`status`,`date_added`,`date_modified`) VALUES
    ('1','1','$date_added','$date_added')");
    $categoryID = mysql_insert_id();
    $query = mysql_query("INSERT INTO oc_category_description (`category_id`,`language_id`,`name`,`meta_title`) VALUES ('$categoryID','3','$kategoriAdi','$kategoriAdi')" );
    $query = mysql_query("INSERT INTO oc_category_path (`category_id`,`path_id`) VALUES ('$categoryID','$categoryID')");
    $query = mysql_query("INSERT INTO oc_category_to_layout (`category_id`) VALUES ('$categoryID')");
    $query = mysql_query("INSERT INTO oc_category_to_store (`category_id`,`store_id`) VALUES ('$categoryID','0')");
    if(!$query){
    echo mysql_error();
    }
    }
    if(count($categoryExp) > 1){
    for($a = 1; $a < count($categoryExp); $a++){
    $kategoriAdi = $categoryExp[$a];
    $categorySql = "SELECT category_id,name FROM oc_category_description WHERE name = '$kategoriAdi' ";
    if(mysql_num_rows(mysql_query($categorySql)) > 0){
    $categoryPrint = mysql_fetch_object(mysql_query($categorySql));
    $categoryID = $categoryPrint->category_id;
    }else{
    $query = mysql_query("INSERT INTO `oc_category`
    (`parent_id`,`column`,`status`,`date_added`,`date_ modified`) VALUES
    ('$categoryID','1','1','$date_added','$date_added' )");
    $categoryID = mysql_insert_id();
    $query = mysql_query("INSERT INTO oc_category_description (`category_id`,`language_id`,`name`,`meta_title`) VALUES ('$categoryID','3','$kategoriAdi','$kategoriAdi')" );
    $query = mysql_query("INSERT INTO oc_category_path (`category_id`,`path_id`) VALUES ('$categoryID','$categoryID')");
    $query = mysql_query("INSERT INTO oc_category_to_layout (`category_id`) VALUES ('$categoryID')");
    $query = mysql_query("INSERT INTO oc_category_to_store (`category_id`,`store_id`) VALUES ('$categoryID','0')");
    if(!$query){
    echo mysql_error();
    }
    }
    }
    }
    // kategori ekletme bitti

    $productSql = "SELECT model,product_id FROM oc_product WHERE model = '$UrunKodu' ";
    if(mysql_num_rows(mysql_query($productSql)) > 0){ // update
    $productPrint = mysql_Fetch_object(mysql_query($productSql));
    $query = mysql_query("UPDATE oc_product SET quantity = '$stok',price='$fiyat' WHERE product_id = '{$productPrint->product_id}'");
    //$query = mysql_query("UPDATE oc_product_description SET name='$UrunAdi',description='$UrunAciklama',meta_t itle='$UrunAdi' WHERE product_id = '{$productPrint->product_id}' ");
    if($query){
    echo 'Bu Ürün zaten var GÜNCELLENDİ! <br>';
    }else{
    echo '<font style="color:red;">Bu Ürün zaten var GÜNCELLENEMEDİ !</font> <br>';
    }
    }else{ // insert

    $profileImg = $urunImg->img_item[0];
    $rand = rand(999,99999999999999).'-'.time().'.jpg';
    $dizin = 'catalog/bt_product/'.$rand;
    $copy = copy($profileImg,'../image/'.$dizin);

    $query = mysql_query("INSERT INTO oc_product
    (image,model,quantity,stock_status_id,shipping,pri ce,date_available,weight_class_id,length_class_id, subtract,minimum,sort_order,status,date_added) VALUES
    ('$dizin','$UrunKodu','$stok','6','1','$fiyat','$d ate_available','1','1','1','1','1','1','$date_adde d','$tax''8',)");
    $urunID = mysql_insert_id();
    if(count($urunImg->img_item) > 1){
    for($i = 1; $i < count($urunImg->img_item); $i++){
    $imgVal = $urunImg->img_item[$i];
    $rand = rand(999,99999999999999.'-'.time().'.jpg';
    $dizin = 'catalog/bt_product/'.$rand;
    $copy = copy($imgVal,'../image/'.$dizin);
    $query = mysql_query("INSERT INTO oc_product_image (product_id,image) VALUES ('$urunID','$dizin')");
    }
    }

    $date_available = date("Y-m-d");
    $query = mysql_query("INSERT INTO oc_product_description
    (product_id,language_id,name,description,meta_titl e) VALUES
    ('$urunID','3','$UrunAdi','$UrunAciklama','$UrunAd i') ");
    $query = mysql_query("INSERT INTO oc_product_to_layout (product_id) VALUES ('$urunID') ");

    if(count($categoryExp) > 0){
    for($a = 0; $a < count($categoryExp); $a++){
    $catName = $categoryExp[$a];
    $printCat = mysql_fetch_object(mysql_query("SELECT category_id,name FROM oc_category_description WHERE name = '$catName' "));
    $query = mysql_query("INSERT INTO oc_product_to_category (product_id,category_id) VALUES ('$urunID','{$printCat->category_id}')");
    }
    }

    $query = mysql_query("INSERT INTO oc_product_to_store (product_id,store_id) VALUES ('$urunID','0')");
    if($query){
    echo 'Ürün Eklendi !<br>';
    }else{
    echo 'Bir hata meydana geldi! <br>';
    }
    }
    }

    ?>
  • 14-01-2020, 12:44:31
    #2
    Xml modulunde sınırlandırabiliyosunuz hocam zaten kod'a gerek yok ama butun urunleri cektiginiz zaman siteniz hostingdeyse vds veya vps taşımanızı öneririm eğer çok ürün var ise hepsini çektiğinizde 503 hatası alırsanız bilin ki hosting kaldırmayacaktır.
  • 14-01-2020, 12:48:32
    #3
    OKirala adlı üyeden alıntı: mesajı görüntüle
    Xml modulunde sınırlandırabiliyosunuz hocam zaten kod'a gerek yok ama butun urunleri cektiginiz zaman siteniz hostingdeyse vds veya vps taşımanızı öneririm eğer çok ürün var ise hepsini çektiğinizde 503 hatası alırsanız bilin ki hosting kaldırmayacaktır.
    sitemde herhangi bir xml modülü yok. bu yukarıdaki xml yolunu yazıp ürün çekiyorum
  • 15-01-2020, 18:24:29
    #4
    fatihkurt adlı üyeden alıntı: mesajı görüntüle
    sitemde herhangi bir xml modülü yok. bu yukarıdaki xml yolunu yazıp ürün çekiyorum
    Hocam şu şekilde yapabilirsiniz en basit
    foreachdan sonra ekleyin, parantezi foreachin bitminden hemen sonra kapatın aşağıda örnekleri mevcut
    eğer $key değerinde rakam yok ise, foreachden önce $key= 0 ; foreachden hemen sonra $key++ olarak yapabilirsiniz

    0 ila 50 yi çekersiniz ,
    foreach($xmlData->product AS $key =>$val){$x++;
    if( ($key > 0 ) && ($key <50) ) {
    
    }//if
    }//foreach
    
    ikinci seferde böyle yaparsınız,
    foreach($xmlData->product AS $key =>$val){$x++;
    if( ($key > 49 ) && ($key <100) ) {
    
    }//if
    }//foreach
    
    veya ben tek tek ugrasmıcam dersen
    get ile baslangic ve değerlerini aldırabilirsin
    xml.php?baslangic=0&bitis=50
    
    $baslangic = $_GET['baslangic'];
    $bitis = $_GET['bitis'];
    if( ($key > $baslangic ) && ($key <$bitis) )
  • 17-01-2020, 11:35:30
    #5
    WebGun adlı üyeden alıntı: mesajı görüntüle
    Hocam şu şekilde yapabilirsiniz en basit
    foreachdan sonra ekleyin, parantezi foreachin bitminden hemen sonra kapatın aşağıda örnekleri mevcut
    eğer $key değerinde rakam yok ise, foreachden önce $key= 0 ; foreachden hemen sonra $key++ olarak yapabilirsiniz

    0 ila 50 yi çekersiniz ,
    foreach($xmlData->product AS $key =>$val){$x++;
    if( ($key > 0 ) && ($key <50) ) {
    
    }//if
    }//foreach
    
    ikinci seferde böyle yaparsınız,
    foreach($xmlData->product AS $key =>$val){$x++;
    if( ($key > 49 ) && ($key <100) ) {
    
    }//if
    }//foreach
    
    veya ben tek tek ugrasmıcam dersen
    get ile baslangic ve değerlerini aldırabilirsin
    xml.php?baslangic=0&bitis=50
    
    $baslangic = $_GET['baslangic'];
    $bitis = $_GET['bitis'];
    if( ($key > $baslangic ) && ($key <$bitis) )
    HTTP ERROR 500 Hatası veriyor yapamadım Yinede teşekkürler
  • 17-01-2020, 11:52:28
    #6
    fatihkurt adlı üyeden alıntı: mesajı görüntüle
    HTTP ERROR 500 Hatası veriyor yapamadım Yinede teşekkürler
    Hocam php.ini den error_log ve display error u acin hatanın sebebini görürsünüz