|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Onurkacmaz\LaravelN11\Models; |
|
4
|
|
|
|
|
5
|
|
|
use Onurkacmaz\LaravelN11\Exceptions\N11Exception; |
|
6
|
|
|
use Onurkacmaz\LaravelN11\Interfaces\CategoryInterface; |
|
7
|
|
|
use Onurkacmaz\LaravelN11\Service; |
|
8
|
|
|
use SoapClient; |
|
9
|
|
|
|
|
10
|
|
|
class Category extends Service implements CategoryInterface |
|
11
|
|
|
{ |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @var SoapClient|null |
|
15
|
|
|
*/ |
|
16
|
|
|
private $_client; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Category constructor |
|
20
|
|
|
* endPoint set edildi. |
|
21
|
|
|
* @throws N11Exception|\SoapFault |
|
22
|
|
|
*/ |
|
23
|
|
|
public function __construct() |
|
24
|
|
|
{ |
|
25
|
|
|
parent::__construct(); |
|
26
|
|
|
$this->_client = $this->setEndPoint(self::END_POINT); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @return mixed |
|
31
|
|
|
* @description Üst Seviye Kategorileri Listeler |
|
32
|
|
|
*/ |
|
33
|
|
|
public function topLevelCategories(): object |
|
34
|
|
|
{ |
|
35
|
|
|
return $this->_client->GetTopLevelCategories($this->_parameters); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param int $categoryId |
|
40
|
|
|
* @param int $currentPage |
|
41
|
|
|
* @param int $pageSize |
|
42
|
|
|
* @return mixed |
|
43
|
|
|
* @description İstenilen kategori, üst seviye kategori veya diğer seviye kategorilerden olabilir, bu kategorilere ait olan özelliklerin ve bu özelliklere ait değerlerin listelenmesi için kullanılan metottur. |
|
44
|
|
|
*/ |
|
45
|
|
|
public function getCategoryAttributes(int $categoryId, int $currentPage = 1, int $pageSize = self::GENERAL_LIMIT): object |
|
46
|
|
|
{ |
|
47
|
|
|
$this->_parameters["categoryId"] = $categoryId; |
|
48
|
|
|
$this->_parameters["pagingData"] = [ |
|
49
|
|
|
"currentPage" => $currentPage, |
|
50
|
|
|
"pageSize" => $pageSize, |
|
51
|
|
|
]; |
|
52
|
|
|
return $this->_client->GetCategoryAttributes($this->_parameters); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @param int $categoryId |
|
57
|
|
|
* @return mixed |
|
58
|
|
|
* @description İstenilen kategori, üst seviye kategori veya diğer seviye kategorilerden olabilir, bu kategorilere ait olan özelliklerin ve bu özelliklere ait değerlerin listelenmesi için kullanılan metottur. |
|
59
|
|
|
*/ |
|
60
|
|
|
public function getCategoryAttributesId(int $categoryId): object |
|
61
|
|
|
{ |
|
62
|
|
|
$this->_parameters["categoryId"] = $categoryId; |
|
63
|
|
|
return $this->_client->GetCategoryAttributesId($this->_parameters); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @param int $categoryProductAttrId |
|
68
|
|
|
* @param int $currentPage |
|
69
|
|
|
* @param int $pageSize |
|
70
|
|
|
* @return mixed |
|
71
|
|
|
* @description Özelliğe ait değerleri listeler |
|
72
|
|
|
*/ |
|
73
|
|
|
public function getCategoryAttributeValue(int $categoryProductAttrId, int $currentPage = 1, int $pageSize = self::GENERAL_LIMIT): object |
|
74
|
|
|
{ |
|
75
|
|
|
$this->_parameters["categoryProductAttributeId"] = $categoryProductAttrId; |
|
76
|
|
|
$this->_parameters["pagingData"] = [ |
|
77
|
|
|
"currentPage" => $currentPage, |
|
78
|
|
|
"pageSize" => $pageSize, |
|
79
|
|
|
]; |
|
80
|
|
|
return $this->_client->GetCategoryAttributeValue($this->_parameters); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @param int $categoryId |
|
85
|
|
|
* @return mixed |
|
86
|
|
|
* @description Kodu verilen kategorinin birinci seviye üst kategorilerine ulaşmak için bu metot kullanılmalıdır. |
|
87
|
|
|
* İkinci seviye üst kategorilere ulaşmak için (Örn. “Deri ayakkabı -> Ayakkabı -> Giysi” kategori ağacında “Giysi “ bilgisi) birinci seviye üst kategorinin (Örn. Ayakkabı) kodu verilerek tekrar servis çağırılmalıdır. |
|
88
|
|
|
* Sorgulanan kategori sistemde bulunamazsa ‘kategori bulunamadı’ hatası alınır. Eğer ilgili kategori herhangi bir üst kategoriye sahip değilse ”parentCategory” bilgisi response içerisinde yer almaz. |
|
89
|
|
|
*/ |
|
90
|
|
|
public function getParentCategory(int $categoryId): object |
|
91
|
|
|
{ |
|
92
|
|
|
$this->_parameters["categoryId"] = $categoryId; |
|
93
|
|
|
return $this->_client->GetParentCategory($this->_parameters); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @param int $categoryId |
|
98
|
|
|
* @return mixed |
|
99
|
|
|
* @description Kodu verilen kategorinin birinci seviye alt kategorilerine ulaşmak için bu metot kullanılmalıdır. |
|
100
|
|
|
* İkinci seviye alt kategorilere ulaşmak için (Örn. “Giysi -> Ayakkabı -> Deri ayakkabı” kategori ağacında “Deri ayakkabı” bilgisi) birinci Seviye alt kategorinin (Örn. Ayakkabı) kodu verilerek tekrar servis çağırılmalıdır. |
|
101
|
|
|
* Sorgulanan kategori sistemde bulunamazsa hata alınır. Eğer ilgili kategori herhangi bir alt kategoriye sahip değilse response bilgisi boş döner. |
|
102
|
|
|
*/ |
|
103
|
|
|
public function getSubCategories(int $categoryId): object |
|
104
|
|
|
{ |
|
105
|
|
|
$this->_parameters["categoryId"] = $categoryId; |
|
106
|
|
|
return $this->_client->GetSubCategories($this->_parameters); |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|