• 16-08-2019, 22:38:49
    #1
    merhaba n11 soap api kullanarak ürünün id numarasını alıp daha sonra stok güncelliyorum fakat 60 saniyede sadece 1 işlem yapabiliyorum. 1300 ürün var tümünü güncellemek uzun zaman alacağı için tek seferde 100 ürün güncellemek istiyorum. en fazla 100 ürün gönderebiliyorum.

    public function GetProductBySellerCode($sellerCode) {
    $this->setUrl('https://api.n11.com/ws/ProductService.wsdl');
    self::$_parameters['sellerCode'] = $sellerCode;
    return self::$_sclient->GetProductBySellerCode(self::$_parameters);
        }
    public function UpdateStockByStockId($id, $quantity) {
    $this->setUrl('https://api.n11.com/ws/ProductStockService.wsdl');
    self::$_parameters['stockItems'] = ['stockItem' => array('id' => $id, 'quantity' => $quantity, 'version' => '1')];
    return self::$_sclient->UpdateStockByStockId(self::$_parameters);
    }
    $n11 = new N11($n11Params);
    
    $getProductBySeller = $n11->GetProductBySellerCode('DOLAP1');
    $n11urunid = $getProductBySeller->product->stockItems->stockItem->id;
    
    $guncelle = $n11->UpdateStockByStockId($n11urunid,20);
    var_dump($guncelle);
    yukarıdaki kodda DOLAP1 kodlu ürünü güncelleyebiliyorum.

    ürün kodlarını veritabanından çekip güncellemek istiyorum.

    bu işlemi toplu yapmak için ne yapmalıyım yardımcı olurmusunuz?
  • 16-08-2019, 22:45:34
    #2
    Döngüleri kullanabilirsin foreach diziler for koşullu işlem için
  • 16-08-2019, 22:55:06
    #3
    ürün kodlarını veritabanından çekip güncellemek istiyorum. dediğin için şöyle birşey yapabilirsin.
    $n11 = new N11($n11Params);
    $sql = "SQL sorgusu"
    $result =$vt->query($sql)->fetch(PDO::FETCH_ASSOC); // burada $vt senin PDO veritabanı değişkenin hangisi ise $db yapan var
    foreach($result as $row){
    $getProductBySeller = $n11->GetProductBySellerCode($row['kolon_adi']);
    $n11urunid = $getProductBySeller->product->stockItems->stockItem->id;
    
    $guncelle = $n11->UpdateStockByStockId($n11urunid,20)
    }
  • 16-08-2019, 23:03:31
    #4
    Üyeliği durduruldu
    while alabilirsin.
  • 16-08-2019, 23:06:37
    #5
    cevaplara bakar mısın? komedi gibi. adamı yanlış anlamışsınız.

    öncelikle şu adrese giriyosunuz: https://api.n11.com/ws/ProductStockService.wsdl

    ardından buradaki metodlara bakıyorsunuz. burada "UpdateStockByStockIdRequest" adında bir metod var. bu metod "auth", "stockItems" adında iki değişken alıyor. "stockItems" değişkeninin tipi "StockItemForUpdateStockWithIdList" bu bir liste. bu veri türünün nasıl oluşturulduğuna bakmak lazım. yukarıda bu tip tanımlanmış zaten. bu tip aslında "StockItemForUpdateStockWithId" veri türünün dizi şekline getirilmiş hali. bu veri türünün nasıl tanımlandığına bakıyoruz. ve tataa işte şu şekilde göndermeniz gerekiyor:

    <xs:element name="id" type="xs:long"/>
    <xs:element name="quantity" type="xs:integer"/>
    <xs:element name="version" type="xs:long"/>
    <xs:element name="delist" nillable="true" type="xs:boolean"/>
    bu veri tipini php'de şu şekilde tanımlayabiliriz:

    array(
        "id" => $id,
        "quantity" => $quantity,
        "version" => 1
        "delist" => false
    )
    ve kodun son hali şu şekilde olmalı:
    public function UpdateStockByStockIdRequest($quantities) {
        $this->setUrl('https://api.n11.com/ws/ProductStockService.wsdl');
        self::$_parameters['stockItems'] = $quantities;
        return self::$_sclient->UpdateStockByStockIdRequest(self::$_parameters);
    }
    
    $n11 = new N11($n11Params);
    $dbQuantities = $db->dataWhereEverYouGet();
    $quantities = array();
    foreach( $dbQuantities as $quantityItem ) {
        $quantities[] = array(
            "id" => $quantityItem->id,
            "quantity" => $quantityItem->quantity,
            "version" => 1
            "delist" => false
        );
    }
    
    $guncelle = $n11->UpdateStockByStockIdRequest($quantities);
    var_dump($guncelle);
    • akaturk
    • _halisoglu_
    akaturk ve _halisoglu_ bunu beğendi.
    2 kişi bunu beğendi.
  • 16-08-2019, 23:07:42
    #6
    sleep(60); deyip 60 saniye döngüyü bekletip güncellersiniz
  • 16-08-2019, 23:14:19
    #7
    kod çalışırsa bilgi verin çünkü denemsini yapmadım. çalışması lazım ama.
    • akaturk
    akaturk bunu beğendi.
    1 kişi bunu beğendi.
  • 17-08-2019, 05:37:42
    #8
    Misafir adlı üyeden alıntı: mesajı görüntüle
    kod çalışırsa bilgi verin çünkü denemsini yapmadım. çalışması lazım ama.
    array(3) { [0]=> array(2) { ["id"]=> string(12) "126336291886" ["quantity"]=> string(2) "11" } [1]=> array(2) { ["id"]=> string(12) "125620429075" ["quantity"]=> string(1) "7" } [2]=> array(2) { ["id"]=> string(12) "125620429070" ["quantity"]=> string(2) "26" } }
    array oluşturdum fakat çalışmadı.

    $n11 = new N11($n11Params);
    include "baglanti.php";
    $sor = "select * FROM oc_product where n11 !='0' order by product_id asc limit 3";
    $query=mysql_query($sor);
    $urunler = array();
    while ($yazdir=mysql_fetch_array($query)) {
    $urunler[] = array(
    "id" => $yazdir['n11'],
    "quantity" => $yazdir['quantity']
    );
    
    }
    $guncelle = $n11->UpdateStockByStockId($urunler);
    var_dump($guncelle );

     public function UpdateStockByStockId($id, $quantity) {
    $this->setUrl('https://api.n11.com/ws/ProductStockService.wsdl');
    self::$_parameters['stockItems'] = ['stockItem' => array('id' => $id, 'quantity' => $quantity, 'version' => '1')];
    return self::$_sclient->UpdateStockByStockId(self::$_parameters);
    }

    <soapenv:Envelopexmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://www.n11.com/ws/schemas">
    <soapenv:Header/>
    <soapenv:Body>
    <sch:UpdateStockByStockIdRequest>
    <auth>
    <appKey>***</appKey>
    <appSecret>***</appSecret>
    </auth>
    <stockItems>
    <!--1 ormorerepetitions:-->
    <stockItem>
    <id>122375331751</id>
    <quantity>10</quantity>
    <version>1</version>
    <delist>1</delist>
    </stockItem>
    </stockItems>
    </sch:UpdateStockByStockIdRequest>
    </soapenv:Body>
    </soapenv:Envelope>
    ürünleri yukarıdaki gibi göndermem gerek. stockItems -> stockItem -> array(id, adet)



    public function UpdateStockByStockId(array $stockItems = Array()) {
    $this->setUrl('https://api.n11.com/ws/ProductStockService.wsdl');
    self::$_parameters['stockItems'] = $stockItems;
    return self::$_sclient->UpdateStockByStockId(self::$_parameters);
    }
    $n11 = new N11($n11Params);
    include "baglanti.php";
    $sor = "select * FROM oc_product order by product_id asc limit 3";
    $query=mysql_query($sor);
    $stockItems = array();
    while ($yazdir=mysql_fetch_array($query)) {    
    
    $stockItems[] = array("id" => $yazdir['n11'], "quantity" => $yazdir['quantity'], "version" => $yazdir['version']);
    
    }
    $guncelle = $n11->UpdateStockByStockId($stockItems);
    var_dump($guncelle);
    bu şekilde çözdüm opencart toplu ürün güncellemesi için kullanabilirsiniz.