Skip to content

Commit 4ae7c92

Browse files
authored
Merge pull request #17 from stb/autocomplete-disable-patch
Allow to disable the autocomplete results
2 parents 29d1719 + e149910 commit 4ae7c92

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

Model/Autocomplete/Post/DataProvider.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,20 @@ public function getType()
110110
public function getItems()
111111
{
112112
$result = [];
113-
$postCollection = $this->getBlogPostCollection();
114-
$i = 0;
115-
if ($postCollection) {
116-
/** @var \Magefan\Blog\Model\Post $post */
117-
foreach ($postCollection as $post) {
118-
$result[] = $this->itemFactory->create([
119-
'title' => $post->getTitle(),
120-
'url' => $post->getPostUrl(),
121-
'type' => $this->getType()]);
122-
$i++;
123-
if ($i == $this->maxAutocompleteResults) {
124-
break;
113+
if ($this->configurationHelper->isEnabled($this->getType())) {
114+
$postCollection = $this->getBlogPostCollection();
115+
$i = 0;
116+
if ($postCollection) {
117+
/** @var \Magefan\Blog\Model\Post $post */
118+
foreach ($postCollection as $post) {
119+
$result[] = $this->itemFactory->create([
120+
'title' => $post->getTitle(),
121+
'url' => $post->getPostUrl(),
122+
'type' => $this->getType()]);
123+
$i++;
124+
if ($i == $this->maxAutocompleteResults) {
125+
break;
126+
}
125127
}
126128
}
127129
}

0 commit comments

Comments
 (0)