Skip to content

Commit 71ef484

Browse files
committed
Added keyword
1 parent 883ec7d commit 71ef484

File tree

6 files changed

+60
-15
lines changed

6 files changed

+60
-15
lines changed

resolver/blog/category.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@ public function get($data) {
99
$thumb = '';
1010
$thumbLazy = '';
1111

12+
$keyword = str_replace(get_site_url(), '', get_term_link((int)$category->ID));
13+
$keyword = trim($keyword, '/?');
14+
$keyword = trim($keyword, '/');
15+
1216
return array(
1317
'id' => $category->ID,
1418
'name' => $category->name,
1519
'description' => $category->description,
1620
'parent_id' => (string) $category->parent,
1721
'image' => $thumb,
22+
'keyword' => $keyword,
1823
'imageLazy' => $thumbLazy,
1924
'url' => function($root, $args) {
2025
return $this->url(array(
@@ -91,6 +96,14 @@ public function url($data) {
9196
$result = str_replace("_id", $category_info['id'], $result);
9297
$result = str_replace("_name", $category_info['name'], $result);
9398

99+
$keyword = str_replace(get_site_url(), '', get_term_link((int)$category_info['id']));
100+
$keyword = trim($keyword, '/?');
101+
$keyword = trim($keyword, '/');
102+
103+
if($keyword != '') {
104+
$result = '/'.$keyword;
105+
}
106+
94107
return $result;
95108
}
96109
}

resolver/blog/post.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@ public function get($args) {
1212
} else {
1313
$thumb = '';
1414
$thumbLazy = '';
15-
}
15+
}
16+
17+
$keyword = str_replace(get_site_url(), '', get_permalink($post->ID));
18+
$keyword = trim($keyword, '/?');
19+
$keyword = trim($keyword, '/');
1620

1721
return array(
1822
'id' => $post->ID,
1923
'title' => $post->title,
2024
'shortDescription' => $post->shortDescription,
2125
'description' => $post->description,
26+
'keyword' => $keyword,
2227
'image' => $thumb,
2328
'imageLazy' => $thumbLazy,
2429
'reviews' => function($root, $args) {

resolver/common/page.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@ public function get($args) {
66
$this->load->model('common/page');
77
$page_info = $this->model_common_page->getPage($args['id']);
88

9+
$keyword = str_replace(get_site_url(), '', get_page_link($page_info->ID));
10+
$keyword = trim($keyword, '/?');
11+
$keyword = trim($keyword, '/');
12+
913
return array(
1014
'id' => $page_info->ID,
1115
'title' => $page_info->title,
1216
'description' => $page_info->description,
13-
'sort_order' => (int)$page_info->sort_order
17+
'sort_order' => (int)$page_info->sort_order,
18+
'keyword' => $keyword
1419
);
1520
}
1621

resolver/store/category.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ public function get($args) {
1616
$thumb = '';
1717
$thumbLazy = '';
1818
}
19-
19+
20+
$keyword = str_replace(get_site_url(), '', get_term_link((int)$category_info->ID));
21+
$keyword = trim($keyword, '/?');
22+
$keyword = trim($keyword, '/');
23+
2024
return array(
2125
'id' => $category_info->ID,
2226
'name' => $category_info->name,
@@ -35,7 +39,8 @@ public function get($args) {
3539
'parent' => $root,
3640
'args' => $args
3741
));
38-
}
42+
},
43+
'keyword' => $keyword
3944
);
4045
}
4146

@@ -100,6 +105,14 @@ public function url($data) {
100105
$result = str_replace("_id", $category_info['id'], $result);
101106
$result = str_replace("_name", $category_info['name'], $result);
102107

108+
$keyword = str_replace(get_site_url(), '', get_term_link((int)$category_info['id']));
109+
$keyword = trim($keyword, '/?');
110+
$keyword = trim($keyword, '/');
111+
112+
if($keyword != '') {
113+
$result = '/'.$keyword;
114+
}
115+
103116
return $result;
104117
}
105118
}

resolver/store/product.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ public function get($args) {
4646
$special = '';
4747
}
4848
}
49+
$keyword = str_replace(get_site_url(), '', get_permalink($product->ID));
50+
$keyword = trim($keyword, '/?');
51+
$keyword = trim($keyword, '/');
4952

5053
$product_info = array(
5154
'id' => $product->ID,
@@ -60,6 +63,7 @@ public function get($args) {
6063
'imageLazy' => $thumbLazy,
6164
'stock' => $product->stock_status === 'instock',
6265
'rating' => (float) $product->rating,
66+
'keyword' => $keyword,
6367
'images' => function($root, $args) {
6468
return $this->getImages(array(
6569
'parent' => $root,

schema.graphql

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type Category {
3030
parent_id: String
3131
url(url: String): String
3232
categories(limit: Int = 3): [Category]
33+
keyword: String
3334
}
3435

3536
type categoryBlog {
@@ -40,6 +41,7 @@ type categoryBlog {
4041
description: String
4142
parent_id: String
4243
url(url: String): String
44+
keyword: String
4345
categories(limit: Int = 3): [categoryBlog]
4446
}
4547

@@ -112,6 +114,7 @@ type Page {
112114
id: ID
113115
title: String
114116
description: String
117+
keyword: String
115118
sort_order: Int
116119
}
117120

@@ -133,6 +136,7 @@ type Post {
133136
description: String
134137
image: String
135138
imageLazy: String
139+
keyword: String
136140
reviews: [postReview]
137141
}
138142

@@ -185,6 +189,7 @@ type Product {
185189
reviews: [productReview]
186190
options: [productOption]
187191
images(limit: Int = 3): [productImage]
192+
keyword: String
188193
}
189194

190195
type productAttribute {
@@ -312,16 +317,15 @@ type RootMutationType {
312317
accountAddAddress(address: AccountAddressInput): AccountAddress
313318
accountEditAddress(id: String, address: AccountAddressInput): AccountAddress
314319
accountRemoveAddress(id: String, page: Int = 1, size: Int = 10): [AccountAddress]
315-
accountCheckLogged: LoggedResult
316-
addBlogPostReview(id: Int, rating: Float, author: String, content: String): Post
317-
addToCart(id: Int, quantity: Int = 1, options: [CartOption] = []): Cart
320+
addBlogPostReview(id: String, rating: Float, author: String, content: String): Post
321+
addToCart(id: String, quantity: Int = 1, options: [CartOption] = []): Cart
318322
updateCart(key: String, quantity: Int = 1): Cart
319323
removeCart(key: String): Cart
320324
addToCompare(id: Int): [Product]
321325
removeCompare(id: String): [Product]
322326
editCurrency(code: String): [Currency]
323327
editLanguage(code: String): [Language]
324-
addReview(id: Int, rating: Float, author: String, content: String): Product
328+
addReview(id: String, rating: Float, author: String, content: String): Product
325329
addToWishlist(id: Int): [Product]
326330
removeWishlist(id: String): [Product]
327331
contactSend(name: String, email: String, message: String): ContactResult
@@ -332,22 +336,23 @@ type RootQueryType {
332336
zonesList(page: Int = 1, size: Int = 10, search: String, country_id: String, sort: String = "name", order: String = "ASC"): ZonesResult
333337
country(id: Int): Country
334338
countriesList(page: Int = 1, size: Int = 10, search: String, sort: String = "name", order: String = "ASC"): CountriesResult
335-
categoryBlog(id: Int): categoryBlog
339+
categoryBlog(id: String): categoryBlog
336340
categoriesBlogList(page: Int = 1, size: Int = 10, filter: String, parent: Int = -1, sort: String = "sort_order", order: String = "ASC"): categoryBlogResult
337-
post(id: Int): Post
338-
postsList(page: Int = 1, size: Int = 10, filter: String, search: String, category_id: Int = 0, sort: String = "sort_order", order: String = "ASC"): PostResult
341+
post(id: String): Post
342+
postsList(page: Int = 1, size: Int = 10, filter: String, search: String, category_id: String = "", sort: String = "sort_order", order: String = "ASC"): PostResult
339343
cart: Cart
340-
category(id: Int): Category
344+
category(id: String): Category
341345
categoriesList(page: Int = 1, size: Int = 10, filter: String, parent: Int = -1, sort: String = "sort_order", order: String = "ASC"): CategoryResult
342346
compare: [Product]
343347
currency: [Currency]
344348
language: [Language]
345-
page(id: Int): Page
349+
page(id: String): Page
346350
pagesList(page: Int = 1, size: Int = 10, search: String = "", sort: String = "sort_order", order: String = "ASC"): PageResult
347-
productsList(page: Int = 1, size: Int = 15, filter: String = "", special: Boolean = false, search: String = "", ids: [Int] = [], category_id: Int = 0, sort: String = "sort_order", order: String = "ASC"): ProductResult
348-
product(id: Int): Product
351+
productsList(page: Int = 1, size: Int = 15, filter: String = "", special: Boolean = false, search: String = "", ids: [Int] = [], category_id: String = "", sort: String = "sort_order", order: String = "ASC"): ProductResult
352+
product(id: String): Product
349353
wishlist: [Product]
350354
contact: Contact
355+
accountCheckLogged: LoggedResult
351356
accountAddressList: [AccountAddress]
352357
accountAddress(id: String): AccountAddress
353358
}

0 commit comments

Comments
 (0)