Skip to content
This repository was archived by the owner on Feb 8, 2023. It is now read-only.

Commit 9c23912

Browse files
committed
Compatible Magento 2.4.2
1 parent ead9c2d commit 9c23912

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

Block/Sitemap.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,24 @@ public function getCategoryUrl($categoryId)
170170

171171
/**
172172
* Get page collection
173-
* @return mixed
173+
*
174+
* @return PageCollection
175+
* @throws NoSuchEntityException
174176
*/
175177
public function getPageCollection()
176178
{
177-
return $this->pageCollection->addFieldToFilter('is_active', Page::STATUS_ENABLED)
178-
->addStoreFilter($this->_storeManager->getStore())
179-
->addFieldToFilter('identifier', [
179+
$excludePages = $this->_helper->getExcludePageListing();
180+
$pageCollection = $this->pageCollection->addFieldToFilter('is_active', Page::STATUS_ENABLED)
181+
->addStoreFilter($this->_storeManager->getStore());
182+
183+
184+
if ($this->_helper->isEnableExcludePage() && !empty($excludePages)) {
185+
$pageCollection->addFieldToFilter('identifier', [
180186
'nin' => $this->getExcludedPages()
181187
]);
188+
}
189+
190+
return $pageCollection;
182191
}
183192

184193
/**
@@ -187,11 +196,7 @@ public function getPageCollection()
187196
*/
188197
public function getExcludedPages()
189198
{
190-
if ($this->_helper->isEnableExcludePage()) {
191-
return explode(',', $this->_helper->getExcludePageListing());
192-
}
193-
194-
return ['home', 'no-route'];
199+
return explode(',', $this->_helper->getExcludePageListing());
195200
}
196201

197202
/**

Model/Source/Page.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,14 @@ public function __construct(CollectionFactory $pageCollectionFactory)
5151
*/
5252
public function toOptionArray()
5353
{
54-
$options = [];
54+
$options[] = [
55+
'value' => '',
56+
'label' => __('-- Please select --')
57+
];
58+
5559
/** @var Collection $collection */
5660
$collection = $this->_pageCollectionFactory->create();
61+
5762
foreach ($collection as $item) {
5863
$options[] = ['value' => $item->getIdentifier(), 'label' => $item->getTitle()];
5964
}

0 commit comments

Comments
 (0)