File tree 1 file changed +43
-0
lines changed 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -277,4 +277,47 @@ public function getPublishDate($format = 'Y-m-d H:i:s')
277
277
$ this ->getData ('creation_time ' )
278
278
);
279
279
}
280
+
281
+ /**
282
+ * @return array|ResourceModel\Comment\Collection
283
+ */
284
+ public function getRepliesCollection ()
285
+ {
286
+ $ repliesCollection = [];
287
+ if (!$ this ->isReply ()) {
288
+ $ cId = $ this ->getId ();
289
+ if (!isset ($ repliesCollection [$ cId ])) {
290
+ $ repliesCollection [$ cId ] = $ this ->getChildComments ()
291
+ ->addActiveFilter ()
292
+ /*->setPageSize($this->getNumberOfReplies())*/
293
+ //->setOrder('creation_time', 'DESC'); old sorting
294
+ ->setOrder ('creation_time ' , 'ASC ' );
295
+ }
296
+
297
+ return $ repliesCollection [$ cId ];
298
+ } else {
299
+ return [];
300
+ }
301
+ }
302
+
303
+ /**
304
+ * @param null $fields
305
+ * @return array
306
+ */
307
+ public function getDynamicData ($ fields = null )
308
+ {
309
+ $ data = $ this ->getData ();
310
+
311
+ if (is_array ($ fields ) && array_key_exists ('replies ' , $ fields )) {
312
+ $ replies = [];
313
+ foreach ($ this ->getRepliesCollection () as $ reply ) {
314
+ $ replies [] = $ reply ->getDynamicData (
315
+ isset ($ fields ['replies ' ]) ? $ fields ['replies ' ] : null
316
+ );
317
+ }
318
+ $ data ['replies ' ] = $ replies ;
319
+ }
320
+
321
+ return $ data ;
322
+ }
280
323
}
You can’t perform that action at this time.
0 commit comments