Skip to content

Commit e99264c

Browse files
committed
updated post url
1 parent 5973e1d commit e99264c

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

Model/Autocomplete/Post/DataProvider.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Smile\ElasticsuiteCore\Helper\Autocomplete as ConfigurationHelper;
1010
use Lof\ElasticsuiteBlog\Model\ResourceModel\Post\Fulltext\CollectionFactory as PostCollectionFactory;
1111
use Smile\ElasticsuiteCore\Model\Autocomplete\Terms\DataProvider as TermDataProvider;
12+
use Ves\Blog\Helper\Data;
1213

1314
/**
1415
* Catalog product autocomplete data provider.
@@ -68,6 +69,11 @@ class DataProvider implements DataProviderInterface
6869
*/
6970
protected $maxAutocompleteResults = 5;
7071

72+
/**
73+
* @var Data
74+
*/
75+
protected $blogHelperData;
76+
7177
/**
7278
* Constructor.
7379
*
@@ -77,6 +83,7 @@ class DataProvider implements DataProviderInterface
7783
* @param postCollectionFactory $postCollectionFactory Post collection factory.
7884
* @param ConfigurationHelper $configurationHelper Autocomplete configuration helper.
7985
* @param StoreManagerInterface $storeManager Store manager.
86+
* @param Data $blogHelperData Ves Blog Helper Data
8087
* @param string $type Autocomplete provider type.
8188
*/
8289
public function __construct(
@@ -86,6 +93,7 @@ public function __construct(
8693
PostCollectionFactory $postCollectionFactory,
8794
ConfigurationHelper $configurationHelper,
8895
StoreManagerInterface $storeManager,
96+
Data $blogHelperData,
8997
$type = self::AUTOCOMPLETE_TYPE
9098
) {
9199
$this->itemFactory = $itemFactory;
@@ -95,6 +103,7 @@ public function __construct(
95103
$this->configurationHelper = $configurationHelper;
96104
$this->type = $type;
97105
$this->storeManager = $storeManager;
106+
$this->blogHelperData = $blogHelperData;
98107
}
99108
/**
100109
* @return string
@@ -117,7 +126,7 @@ public function getItems()
117126
foreach ($postCollection as $post) {
118127
$result[] = $this->itemFactory->create([
119128
'title' => $post->getTitle(),
120-
'url' => $post->getPostUrl(),
129+
'url' => $this->blogHelperData->getPostUrl($post),
121130
'type' => $this->getType()]);
122131
$i++;
123132
if ($i == $this->maxAutocompleteResults) {
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php /** @var \Lof\ElasticsuiteBlog\Block\Post\Result */ ?>
2+
<?php $helper = $this->helper("Ves\Blog\Helper\Data"); ?>
23
<div class="search results">
3-
<h2><?php echo __('Results in blog post.')?></h2>
4+
<h2><?= __('Results in blog post.')?></h2>
45

56
<ul>
67
<?php foreach ($block->getPostCollection() as $currentPost) : ?>
7-
<li><a href="<?php echo $currentPost->getPostUrl()?>"><?php echo $currentPost->getTitle(); ?></a></li>
8+
<li><a href="<?= $helper->getPostUrl($currentPost);?>"><?= $currentPost->getTitle(); ?></a></li>
89
<?php endforeach; ?>
910
</ul>
1011
</div>
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?php /** @var \Lof\ElasticsuiteBlog\Block\Post\Suggest */ ?>
2+
<?php $helper = $this->helper("Ves\Blog\Helper\Data"); ?>
23
<?php if ($block->canShowBlock()): ?>
34
<div class="search results">
4-
<h2><?php echo __('Results in blog posts.')?></h2>
5+
<h2><?= __('Results in blog posts.')?></h2>
56

67
<ul>
78
<?php foreach ($block->getPostCollection() as $currentPost) : ?>
8-
<li><a href="<?php echo $currentPost->getPostUrl()?>"><?php echo $currentPost->getTitle(); ?></a></li>
9+
<li><a href="<?= $helper->getPostUrl($currentPost); ?>"><?= $currentPost->getTitle(); ?></a></li>
910
<?php endforeach; ?>
1011
</ul>
11-
<a href="<?php echo $block->getShowAllUrl()?>"><?php echo __('Show more.')?></a>
12+
<a href="<?= $block->getShowAllUrl()?>"><?= __('Show more.')?></a>
1213
</div>
1314
<?php endif; ?>

0 commit comments

Comments
 (0)