Skip to content

Commit 2d30c02

Browse files
committed
Added new API
1 parent e637aee commit 2d30c02

File tree

9 files changed

+3585
-2999
lines changed

9 files changed

+3585
-2999
lines changed

Vuefront/Vuefront/ApiGraphql/cached_schema.php

Lines changed: 3494 additions & 2998 deletions
Large diffs are not rendered by default.

Vuefront/Vuefront/ApiGraphql/mapping.json

100755100644
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
"accountEditAddress": "common/account/editAddress",
1212
"accountRemoveAddress": "common/account/removeAddress",
1313

14+
"home": "common/home/get",
15+
1416
"uploadFile": "common/file/upload",
1517

1618
"countriesList": "common/country/getList",

Vuefront/Vuefront/ApiGraphql/resolver/blog/category.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ public function get($data)
5656
'args' => $args,
5757
'category' => $category
5858
));
59+
},
60+
'meta' => function() use ($category) {
61+
return array(
62+
'title' => $category->getMetaTitle() != '' ? $category->getMetaTitle() : $category->getTitle(),
63+
'description' => $category->getMetaDescription(),
64+
'keyword' => $category->getMetaKeywords()
65+
);
5966
}
6067
);
6168
} else {

Vuefront/Vuefront/ApiGraphql/resolver/blog/post.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ public function get($args)
8888
'args' => $args,
8989
'post' => $post
9090
));
91+
},
92+
'meta' => function() use ($post) {
93+
return array(
94+
'title' => $post->getMetaTitle() != '' ? $post->getMetaTitle() : $post->getTitle(),
95+
'description' => $post->getMetaDescription(),
96+
'keyword' => $post->getMetaKeywords()
97+
);
9198
}
9299
);
93100
} else {
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
use \Magento\Framework\App\ObjectManager;
4+
5+
require_once VF_SYSTEM_DIR . 'engine/resolver.php';
6+
/**
7+
* @property \Magento\Cms\Model\PageFactory $_pageFactory
8+
* @property \Magento\Framework\App\Config\ScopeConfigInterface $_scopeConfig
9+
*/
10+
class ResolverCommonHome extends Resolver
11+
{
12+
private $codename = "d_vuefront";
13+
14+
private $_pageFactory;
15+
private $_scopeConfig;
16+
17+
public function __construct($registry)
18+
{
19+
parent::__construct($registry);
20+
$objectManager = ObjectManager::getInstance();
21+
$this->_pageFactory = $objectManager->get('\Magento\Cms\Model\PageFactory');
22+
$this->_scopeConfig = $objectManager->get('\Magento\Framework\App\Config\ScopeConfigInterface');
23+
}
24+
25+
public function get($args)
26+
{
27+
$page_id = $this->_scopeConfig->getValue('web/default/cms_home_page', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
28+
$page = $this->_pageFactory->create()->load($page_id);
29+
return array(
30+
'meta' => array(
31+
'title' => $page->getMetaTitle() !== ''? $page->getTitle() : $page->getTitle(),
32+
'description' => $page->getMetaDescription(),
33+
'keyword' => $page->getMetaKeywords()
34+
)
35+
);
36+
}
37+
}

Vuefront/Vuefront/ApiGraphql/resolver/common/page.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ public function get($args)
3333
},
3434
'keyword' => function () use ($page) {
3535
return $page->getIdentifier();
36+
},
37+
'meta' => function() use ($page) {
38+
return array(
39+
'title' => $page->getMetaTitle() != '' ? $page->getMetaTitle() : $page->getTitle(),
40+
'description' => $page->getMetaDescription(),
41+
'keyword' => $page->getMetaKeywords()
42+
);
3643
}
3744
);
3845
}

Vuefront/Vuefront/ApiGraphql/resolver/store/category.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function __construct($registry)
2222
public function get($args)
2323
{
2424
$this->load->model('store/category');
25-
25+
/** @var $category Magento\Catalog\Model\Category */
2626
if (!isset($args['category'])) {
2727
$category = $this->model_store_category->getCategory($args['id']);
2828
} else {
@@ -66,6 +66,13 @@ public function get($args)
6666
},
6767
'keyword' => function () use ($category) {
6868
return !empty($category->getUrlKey()) ? $category->getUrlKey().$this->_suffix: "";
69+
},
70+
'meta' => function() use ($category) {
71+
return array(
72+
'title' => $category->getMetaTitle() != '' ? $category->getMetaTitle() : $category->getName(),
73+
'description' => $category->getMetaDescription(),
74+
'keyword' => $category->getMetaKeywords()
75+
);
6976
}
7077
);
7178
}

Vuefront/Vuefront/ApiGraphql/resolver/store/product.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,13 @@ public function get($args)
161161
'args' => $args,
162162
'product' => $product
163163
));
164+
},
165+
'meta' => function() use ($product) {
166+
return array(
167+
'title' => $product->getMetaTitle() != '' ? $product->getMetaTitle() : $product->getName(),
168+
'description' => $product->getMetaDescription(),
169+
'keyword' => $product->getMetaKeywords()
170+
);
164171
}
165172
);
166173
}

Vuefront/Vuefront/ApiGraphql/schema.graphql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type Category {
3939
url(url: String): String
4040
categories(limit: Int = 3): [Category]
4141
keyword: String
42+
meta: Meta
4243
}
4344

4445
type categoryBlog {
@@ -51,6 +52,7 @@ type categoryBlog {
5152
url(url: String): String
5253
keyword: String
5354
categories(limit: Int = 3): [categoryBlog]
55+
meta: Meta
5456
}
5557

5658
type categoryBlogResult {
@@ -125,6 +127,7 @@ type Page {
125127
name: String
126128
description: String
127129
keyword: String
130+
meta: Meta
128131
sort_order: Int
129132
}
130133

@@ -159,6 +162,7 @@ type Post {
159162
datePublished: String
160163
next: Post
161164
prev: Post
165+
meta: Meta
162166
}
163167

164168
type PostResult {
@@ -211,6 +215,7 @@ type Product {
211215
options: [productOption]
212216
images(limit: Int = 3): [productImage]
213217
keyword: String
218+
meta: Meta
214219
}
215220

216221
type productAttribute {
@@ -332,6 +337,16 @@ type CheckoutLinkResult {
332337
link: String
333338
}
334339

340+
type Meta {
341+
title: String
342+
description: String
343+
keyword: String
344+
}
345+
346+
type HomeResult {
347+
meta: Meta
348+
}
349+
335350
type RootMutationType {
336351
uploadFile(file: Upload): FileResult
337352
accountLogin(email: String, password: String): Customer
@@ -357,6 +372,7 @@ type RootMutationType {
357372
}
358373

359374
type RootQueryType {
375+
home: HomeResult
360376
zone(id: Int): Zone
361377
zonesList(page: Int = 1, size: Int = 10, search: String, country_id: String, sort: String = "name", order: String = "ASC"): ZonesResult
362378
country(id: Int): Country

0 commit comments

Comments
 (0)