Ürün Kategorileri
Bir grubun içindeki ürün kategorilerini okuyan, açan, düzenleyen, silen ve görsellerini yöneten altı uç.
Genel Bakış
Kategori, bir grubun içinde ürünleri toplayan kaptır. Kategorilerin düz listesi ürün uçları makalesindeki arama ucundan gelir; buradaki altı uç tek bir kategoriyi okur, açar, düzenler, siler ve görsellerini yönetir.
Kategoriler ile özel gruplar aynı tabloda yaşar ve aynı şemayı döndürür. Hangisine baktığınızı is_category alanından okursunuz.
Referans
Kategori Detayı
Tek bir kategoriyi tüm ayarları ve dil içeriğiyle döndürür.
active ya da inactive.visible ya da invisible.font ya da image.curl 'https://panel.ornek.com/api/v1/admin/products/categories/18' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/products/categories/18', {
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/categories/18');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Products()->GetProductCategory(['id' => 18]);
// is_category, satirin kategori mi ust seviye grup mu oldugunu soyler.
$isCategory = $response['data']['is_category'];Kategori Oluşturma
Bir grubun içinde kategori açar. Hangi gruba gireceğini tek bir alan belirler.
hosting, server, software ya da özel grup için kimlik son ekli anahtar. Grup listesi ucundan alınır.active ya da inactive.font ya da image.201 ile döner. Yukarıdaki kategori detayıyla aynı şemadır.group boş.sub_title değeri 255 karakterden uzun.curl -X POST 'https://panel.ornek.com/api/v1/admin/products/categories' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"group":"hosting","title":{"en":"Reseller Hosting"},"rank":2}'const res = await fetch('https://panel.ornek.com/api/v1/admin/products/categories', {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
group: 'hosting',
title: { en: 'Reseller Hosting' },
rank: 2,
}),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/categories');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'group' => 'hosting',
'title' => ['en' => 'Reseller Hosting'],
'rank' => 2,
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Ozel grup icin anahtar kimlik son ekiyle gelir; grup listesinden okuyun.
$response = Api::Products()->CreateProductCategory([
'group' => 'special-5',
'title' => ['en' => 'Wildcard Certificates'],
]);Kategoriyi Güncelleme
Gönderdiğiniz alanları uygular. Kategorinin bağlı olduğu grup bu uçtan değiştirilemez.
active ya da inactive.font ya da image.200 ile döner. Yukarıdaki kategori detayıyla aynı şemadır.sub_title değeri 255 karakterden uzun.curl -X PATCH 'https://panel.ornek.com/api/v1/admin/products/categories/18' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"status":"inactive","rank":5}'const res = await fetch('https://panel.ornek.com/api/v1/admin/products/categories/18', {
method: 'PATCH',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ status: 'inactive', rank: 5 }),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/categories/18');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['status' => 'inactive', 'rank' => 5]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Products()->UpdateProductCategory([
'id' => 18,
'status' => 'inactive',
'rank' => 5,
]);Kategoriyi Silme
Kategoriyi siler.
gate:product.group_delete kancası işlemi veto etti.curl -X DELETE 'https://panel.ornek.com/api/v1/admin/products/categories/18' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/products/categories/18', {
method: 'DELETE',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/categories/18');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Products()->DeleteProductCategory(['id' => 18]);Kategori Görseli Yükleme
Kategorinin ikonunu ya da başlık arka planını yükler.
icon ya da header-background. Varsayılan icon.icon ya da header-background.curl -X POST 'https://panel.ornek.com/api/v1/admin/products/categories/18/image' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"image":"https://cdn.example.com/icon.png","type":"icon"}'const res = await fetch('https://panel.ornek.com/api/v1/admin/products/categories/18/image', {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
image: 'https://cdn.example.com/icon.png',
type: 'icon',
}),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/categories/18/image');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'image' => 'https://cdn.example.com/icon.png',
'type' => 'icon',
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Gorsel ikon yuklemek ikon tipini de 'image' yapar; font ikonu artik gecerli degildir.
$response = Api::Products()->UploadCategoryImage([
'id' => 18,
'image' => 'https://cdn.example.com/icon.png',
'type' => 'icon',
]);Kategori Görselini Silme
Kategorinin ikonunu ya da başlık arka planını kaldırır.
icon ya da header-background. Varsayılan icon.curl -X DELETE -G 'https://panel.ornek.com/api/v1/admin/products/categories/18/image' \
-H "Authorization: Bearer $API_KEY" \
-d type=header-backgroundconst url = new URL('https://panel.ornek.com/api/v1/admin/products/categories/18/image');
url.searchParams.set('type', 'header-background');
const res = await fetch(url, {
method: 'DELETE',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$url = 'https://panel.ornek.com/api/v1/admin/products/categories/18/image?' . http_build_query(['type' => 'header-background']);
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Products()->DeleteProductCategoryImage(['id' => 18], [
'type' => 'header-background',
]);Tuzaklar
Kategorinin hangi gruba ait olduğu group alanıyla açılışta belirlenir ve sonradan değiştirilemez; güncelleme gövdesinde böyle bir alan yoktur. Kategoriyi başka bir gruba taşımak için yenisini açıp eskisini silmeniz gerekir.
Adres parçası çakışırsa hem oluşturma hem güncelleme reddedilir. Çakışma yalnız kardeş kategoriler arasında değil, kayıtlar arasında aranır: başka bir gruptaki aynı adlı kategori de sizi durdurur. Başlıktan üretilen adresler bu yüzden beklenmedik biçimde çakışabilir.
İkon yuvasına görsel yüklemek ikon tipini görsele çevirir; daha önce ayarladığınız font ikonu kaydedilse de gösterilmez. Font ikonuna dönmek için görseli silip ikon tipini geri yazmanız gerekir.
İlgili Makaleler
Geri bildiriminiz için teşekkürler!
Yukarıda bulamadığınız her şey için destek ekibimiz her zaman yanınızda.