1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Onurkacmaz\LaravelN11\Models; |
4
|
|
|
|
5
|
|
|
use Onurkacmaz\LaravelN11\Exceptions\N11Exception; |
6
|
|
|
use Onurkacmaz\LaravelN11\Service; |
7
|
|
|
use SoapClient; |
8
|
|
|
|
9
|
|
|
class Category extends Service |
10
|
|
|
{ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @var SoapClient|null |
14
|
|
|
*/ |
15
|
|
|
private $_client = null; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var string |
19
|
|
|
*/ |
20
|
|
|
private $endPoint = "/CategoryService.wsdl"; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Category constructor |
24
|
|
|
* endPoint set edildi. |
25
|
|
|
* @throws N11Exception|\SoapFault |
26
|
|
|
*/ |
27
|
|
|
public function __construct() |
28
|
|
|
{ |
29
|
|
|
parent::__construct(); |
30
|
|
|
$this->_client = $this->setEndPoint($this->endPoint); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @return mixed |
35
|
|
|
* @description Üst Seviye Kategorileri Listeler |
36
|
|
|
*/ |
37
|
|
|
public function topLevelCategories() |
38
|
|
|
{ |
39
|
|
|
return $this->_client->GetTopLevelCategories($this->_parameters); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param int $categoryId |
44
|
|
|
* @param int $currentPage |
45
|
|
|
* @param int $pageSize |
46
|
|
|
* @return mixed |
47
|
|
|
* @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. |
48
|
|
|
*/ |
49
|
|
View Code Duplication |
public function getCategoryAttributes(int $categoryId, int $currentPage = 1, int $pageSize = 100) { |
|
|
|
|
50
|
|
|
$this->_parameters["categoryId"] = $categoryId; |
51
|
|
|
$this->_parameters["pagingData"] = [ |
52
|
|
|
"currentPage" => $currentPage, |
53
|
|
|
"pageSize" => $pageSize, |
54
|
|
|
]; |
55
|
|
|
return $this->_client->GetCategoryAttributes($this->_parameters); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param int $categoryId |
60
|
|
|
* @return mixed |
61
|
|
|
* @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. |
62
|
|
|
*/ |
63
|
|
|
public function getCategoryAttributesId(int $categoryId) { |
64
|
|
|
$this->_parameters["categoryId"] = $categoryId; |
65
|
|
|
return $this->_client->GetCategoryAttributesId($this->_parameters); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param int $categoryProductAttrId |
70
|
|
|
* @param int $currentPage |
71
|
|
|
* @param int $pageSize |
72
|
|
|
* @return mixed |
73
|
|
|
* @description Özelliğe ait değerleri listeler |
74
|
|
|
*/ |
75
|
|
View Code Duplication |
public function getCategoryAttributeValue(int $categoryProductAttrId, int $currentPage = 1, int $pageSize = 100) { |
|
|
|
|
76
|
|
|
$this->_parameters["categoryProductAttributeId"] = $categoryProductAttrId; |
77
|
|
|
$this->_parameters["pagingData"] = [ |
78
|
|
|
"currentPage" => $currentPage, |
79
|
|
|
"pageSize" => $pageSize, |
80
|
|
|
]; |
81
|
|
|
return $this->_client->GetCategoryAttributeValue($this->_parameters); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param int $categoryId |
86
|
|
|
* @return mixed |
87
|
|
|
* @description Kodu verilen kategorinin birinci seviye üst kategorilerine ulaşmak için bu metot kullanılmalıdır. |
88
|
|
|
* İ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. |
89
|
|
|
* 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. |
90
|
|
|
*/ |
91
|
|
|
public function getParentCategory(int $categoryId) { |
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) { |
104
|
|
|
$this->_parameters["categoryId"] = $categoryId; |
105
|
|
|
return $this->_client->GetSubCategories($this->_parameters); |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.