File tree Expand file tree Collapse file tree 4 files changed +19
-25
lines changed Expand file tree Collapse file tree 4 files changed +19
-25
lines changed Original file line number Diff line number Diff line change @@ -42,10 +42,11 @@ public function __construct(
42
42
43
43
/**
44
44
* @param string $postId
45
+ * @param array|null $fields
45
46
* @return array
46
47
* @throws NoSuchEntityException
47
48
*/
48
- public function getData (string $ postId ): array
49
+ public function getData (string $ postId, $ fields = null ): array
49
50
{
50
51
$ post = $ this ->postRepository ->getFactory ()->create ();
51
52
$ post ->getResource ()->load ($ post , $ postId );
@@ -54,6 +55,6 @@ public function getData(string $postId): array
54
55
throw new NoSuchEntityException ();
55
56
}
56
57
57
- return $ post ->getDynamicData ();
58
+ return $ post ->getDynamicData ($ fields );
58
59
}
59
60
}
Original file line number Diff line number Diff line change @@ -45,7 +45,14 @@ public function resolve(
45
45
array $ args = null
46
46
) {
47
47
$ postId = $ this ->getPostId ($ args );
48
- $ postData = $ this ->getPostData ($ postId );
48
+ $ fields = $ info ? $ info ->getFieldSelection (10 ) : null ;
49
+
50
+ try {
51
+ $ postData = $ this ->postDataProvider ->getData ($ postId , $ fields );
52
+ } catch (NoSuchEntityException $ e ) {
53
+ throw new GraphQlNoSuchEntityException (__ ($ e ->getMessage ()), $ e );
54
+ }
55
+
49
56
return $ postData ;
50
57
}
51
58
@@ -62,19 +69,4 @@ private function getPostId(array $args): string
62
69
63
70
return (string )$ args ['id ' ];
64
71
}
65
-
66
- /**
67
- * @param string $postId
68
- * @return array
69
- * @throws GraphQlNoSuchEntityException
70
- */
71
- private function getPostData (string $ postId ): array
72
- {
73
- try {
74
- $ postData = $ this ->postDataProvider ->getData ($ postId );
75
- } catch (NoSuchEntityException $ e ) {
76
- throw new GraphQlNoSuchEntityException (__ ($ e ->getMessage ()), $ e );
77
- }
78
- return $ postData ;
79
- }
80
72
}
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ public function resolve(
75
75
76
76
if (isset ($ args ['sort ' ])) {
77
77
$ sortOrder = $ this ->sortOrderBuilder
78
- ->setField ($ args ['sortFiled ' ])
78
+ ->setField (isset ( $ args ['sortFiled ' ]) ? $ args [ ' sortFiled ' ] : ' update_time ' )
79
79
->setDirection ($ args ['sort ' ][0 ])
80
80
->create ();
81
81
$ searchCriteria ->setSortOrders ([$ sortOrder ]);
@@ -101,9 +101,13 @@ public function resolve(
101
101
}
102
102
103
103
$ items = $ searchResult ->getItems ();
104
+ $ fields = $ info ? $ info ->getFieldSelection (10 ) : null ;
104
105
105
106
foreach ($ items as $ k => $ data ) {
106
- $ items [$ k ] = $ this ->postDataProvider ->getData ($ data ['post_id ' ]);
107
+ $ items [$ k ] = $ this ->postDataProvider ->getData (
108
+ $ data ['post_id ' ],
109
+ isset ($ fields ['items ' ]) ? $ fields ['items ' ] : null
110
+ );
107
111
}
108
112
109
113
return [
Original file line number Diff line number Diff line change @@ -116,11 +116,8 @@ type BlogPost {
116
116
views_count : Int @doc (description : " Blog Post Views count" )
117
117
is_recent_posts_skip : Int @doc (description : " Blog Post Is recent posts skip" )
118
118
short_content : String @doc (description : " Blog Post Short content" )
119
- #fb_auto_publish: Int @doc(description: "Blog Post Fb auto publish")
120
- #fb_post_format: String @doc(description: "Blog Post Fb post format")
121
- #fb_published: Int @doc(description: "Blog Post Fb published")
122
- #rp_conditions_serialized: String @doc(description: "Blog Post Rp conditions serialized")
123
- #rp_conditions_generation_time: String @doc(description: "Blog Post Rp conditions generation time")
119
+ related_posts : [BlogPost ] @doc (description : " Blog Related posts" )
120
+ related_products : [String ] @doc (description : " Blog Related products" )
124
121
}
125
122
126
123
type BlogCategory {
You can’t perform that action at this time.
0 commit comments