Daha önce N11 için SAOP kulanarak ürünlerimizi nasıl göndereceğimizi, siparişleri nasıl listeleyebileceğimizi vb. anlatmıştık ve çok ilgi görmüştü. Şimdi Sanal Pazar için aynı şekilde bir paylaşım hazırladım umarım işinize yarar. Sanal Pazar Api Entegrasyonu PHP Sınıfımız:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
<?php class SP { protected static $_username, $_password, $_parameters, $_sclient, $_token; public function __construct(array $attributes = array()) { self::$_username = $attributes[0]; self::$_password = $attributes[1]; } public static function setUrl($url) { self::$_sclient = new \SoapClient($url); self::$_token = self::$_sclient->login(self::$_username, self::$_password); } public static function getNewCategoryList($parent_id) { self::setUrl('http://www.sanalpazar.com/webservice/sp.wsdl'); return json_decode(self::$_sclient->getCategoryList(self::$_token,$parent_id)); } public static function getStoreCategoryList() { self::setUrl('http://www.sanalpazar.com/webservice/sp.wsdl'); return json_decode(self::$_sclient->getStoreCategoryList(self::$_token)); } public static function getCategoryAttributeSetList($cId) { self::setUrl('http://www.sanalpazar.com/webservice/sp.wsdl'); return json_decode(self::$_sclient->getCategoryAttributeSetList(self::$_token, $cId)); } public static function getCategoryVariantSetList($cId) { self::setUrl('http://www.sanalpazar.com/webservice/sp.wsdl'); return json_decode(self::$_sclient->getCategoryVariantSetList(self::$_token, $cId)); } public static function getOrderList($start_date,$end_date,$status) { self::setUrl('http://www.sanalpazar.com/webservice/sp.wsdl'); return json_decode(self::$_sclient->getOrderList(self::$_token,$start_date,$end_date,$status)); } public static function getOrderDetails($sc) { self::setUrl('http://www.sanalpazar.com/webservice/sp.wsdl'); return json_decode(self::$_sclient->getOrderDetails(self::$_token,$sc)); } public static function getOrderStatus($sc) { self::setUrl('http://www.sanalpazar.com/webservice/sp.wsdl'); return json_decode(self::$_sclient->getOrderStatus(self::$_token,$sc)); } public static function getCargoFirmList() { self::setUrl('http://www.sanalpazar.com/webservice/sp.wsdl'); return json_decode(self::$_sclient->getCargoFirmList(self::$_token)); } public static function updateCargoCode() { self::setUrl('http://www.sanalpazar.com/webservice/sp.wsdl'); return json_decode(self::$_sclient->updateCargoCode(self::$_token)); } public static function addProduct($product_data) { self::setUrl('http://www.sanalpazar.com/webservice/sp.wsdl'); return json_decode(self::$_sclient->addProduct(self::$_token,$product_data)); } public static function updateProductCategory($urunid,$kategoriid) { self::setUrl('http://www.sanalpazar.com/webservice/sp.wsdl'); return json_decode(self::$_sclient->updateProductCategory(self::$_token,$urunid,$kategoriid)); } public static function updateProductPrice($urunid,$fiyat) { self::setUrl('http://www.sanalpazar.com/webservice/sp.wsdl'); return json_decode(self::$_sclient->updateProductPrice(self::$_token,$urunid,$fiyat)); } public static function updateProductQty($urunid,$stok) { self::setUrl('http://www.sanalpazar.com/webservice/sp.wsdl'); return json_decode(self::$_sclient->updateProductQty(self::$_token,$urunid,$stok)); } public static function updateProductShippingDay($urunid,$kargogun) { self::setUrl('http://www.sanalpazar.com/webservice/sp.wsdl'); return json_decode(self::$_sclient->updateProductShippingDay(self::$_token,$urunid,$kargogun)); } public static function updateProductShippingPayType($urunid,$kargotipi) { self::setUrl('http://www.sanalpazar.com/webservice/sp.wsdl'); return json_decode(self::$_sclient->updateProductShippingPayType(self::$_token,$urunid,$kargotipi)); } public static function updateProduct($urunid,$duzenlenenurun) { self::setUrl('http://www.sanalpazar.com/webservice/sp.wsdl'); return json_decode(self::$_sclient->updateProduct(self::$_token,$urunid,$duzenlenenurun)); } public static function closeProduct($urunid) { self::setUrl('http://www.sanalpazar.com/webservice/sp.wsdl'); return json_decode(self::$_sclient->closeProduct(self::$_token,$urunid)); } public static function deleteProduct($urunid) { self::setUrl('http://www.sanalpazar.com/webservice/sp.wsdl'); return json_decode(self::$_sclient->deleteProduct(self::$_token,$urunid)); } public static function getProductList($start,$end) { self::setUrl('http://www.sanalpazar.com/webservice/sp.wsdl'); return json_decode(self::$_sclient->getProductList(self::$_token,$start,$end)); } public static function getProductDetails($urunid) { self::setUrl('http://www.sanalpazar.com/webservice/sp.wsdl'); return json_decode(self::$_sclient->getProductDetails(self::$_token,$urunid)); } } |
Bir kaç örnekle kullanımından bahsedelim. Sanal Pazar Ürünlerimizi Nasıl Listeleriz?
1 2 3 |
$sp = new SP(['XXXXXX', 'XXXXXX']); $urunListesi = $sp::getProductList(0, 100); print_r($urunListesi); |
Sanal Pazar Siparişleri Listeleme
1 2 3 |
$sp = new SP(['XXXXXX', 'XXXXXX']); $siparisListesi = $sp::getOrderList('2016-04-10 00:00:00','2016-04-16 00:00:00','KARGO_GONDERIMI_BEKLENIYOR'); print_r($siparisListesi); |
Sanal Pazar Sipariş Detayını ÇekmeDevamı…