-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathFull.php
More file actions
executable file
·85 lines (75 loc) · 2.49 KB
/
Full.php
File metadata and controls
executable file
·85 lines (75 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
namespace Comwrap\ElasticsuiteBlog\Model\Post\Indexer\Fulltext\Action;
use Comwrap\ElasticsuiteBlog\Model\ResourceModel\Post\Indexer\Fulltext\Action\Full as ResourceModel;
use Magento\Cms\Model\Template\FilterProvider;
#[\AllowDynamicProperties]
class Full
{
/**
* @var \Comwrap\ElasticsuiteBlog\Model\ResourceModel\Post\Indexer\Fulltext\Action\Full
*/
private $resourceModel;
/**
* @var \Magento\Cms\Model\Template\FilterProvider
*/
private $filterProvider;
/**
* Constructor.
*
* @param ResourceModel $resourceModel Indexer resource model.
* @param FilterProvider $filterProvider Model template filter provider.
*/
public function __construct(ResourceModel $resourceModel, FilterProvider $filterProvider)
{
$this->resourceModel = $resourceModel;
$this->filterProvider = $filterProvider;
}
/**
* Get data for a list of blog posts in a store id.
*
* @param integer $storeId Store id.
* @param array|null $blogPostIds List of cms page ids.
*
* @return \Traversable
*/
public function rebuildStoreIndex($storeId, $blogPostIds = null)
{
$lastBlogPostId = 0;
do {
$blogPosts = $this->getSearchableBlogPost($storeId, $blogPostIds, $lastBlogPostId);
foreach ($blogPosts as $postData) {
$postData = $this->processPostData($postData);
$lastBlogPostId = (int) $postData['post_id'];
yield $lastBlogPostId => $postData;
}
} while (!empty($blogPosts));
}
/**
* Load a bulk of blog post data.
*
* @param int $storeId Store id.
* @param string $blogPostIds Blog post ids filter.
* @param integer $fromId Load product with id greater than.
* @param integer $limit Number of product to get loaded.
*
* @return array
*/
private function getSearchableBlogPost($storeId, $blogPostIds = null, $fromId = 0, $limit = 100)
{
return $this->resourceModel->getSearchableBlogPost($storeId, $blogPostIds, $fromId, $limit);
}
/**
* Parse template processor blog poct content
*
* @param array $postData Blog post data.
*
* @return array
*/
private function processPostData($postData)
{
if (isset($postData['content'])) {
$postData['content'] = $this->filterProvider->getPageFilter()->filter($postData['content']);
}
return $postData;
}
}