Skip to content

Commit 79a49d3

Browse files
authored
Merge pull request #18 from ivanhrytsaim/10935-Create-Default-Rule
Exclude Page
2 parents 1585556 + e90c85e commit 79a49d3

File tree

2 files changed

+86
-1
lines changed

2 files changed

+86
-1
lines changed

Setup/Patch/Data/PageToExclude.php

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
/**
3+
* Copyright © Magefan (support@magefan.com). All rights reserved.
4+
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magefan\HtmlSitemap\Setup\Patch\Data;
10+
11+
use Magento\Cms\Model\ResourceModel\Page\CollectionFactory as PageCollectionFactory;
12+
use Magento\Framework\Setup\ModuleDataSetupInterface;
13+
use Magento\Framework\Setup\Patch\DataPatchInterface;
14+
use Magento\Framework\Setup\Patch\PatchRevertableInterface;
15+
16+
class PageToExclude implements DataPatchInterface, PatchRevertableInterface
17+
{
18+
19+
/**
20+
* @var ModuleDataSetupInterface
21+
*/
22+
private $moduleDataSetup;
23+
24+
/**
25+
* @var PageCollectionFactory
26+
*/
27+
private $pageCollectionFactory;
28+
29+
/**
30+
* @param ModuleDataSetupInterface $moduleDataSetup
31+
* @param PageCollectionFactory $pageCollectionFactory
32+
*/
33+
public function __construct(
34+
ModuleDataSetupInterface $moduleDataSetup,
35+
PageCollectionFactory $pageCollectionFactory
36+
)
37+
{
38+
$this->moduleDataSetup = $moduleDataSetup;
39+
$this->pageCollectionFactory = $pageCollectionFactory;
40+
}
41+
42+
/**
43+
* @return void
44+
*/
45+
public function apply()
46+
{
47+
$this->moduleDataSetup->getConnection()->startSetup();
48+
49+
$pageCollection = $this->pageCollectionFactory->create();
50+
51+
$pageCollection->addFieldToFilter('identifier', ['in' => ['no-route', 'home', 'enable-cookies']]);
52+
53+
foreach ($pageCollection as $page) {
54+
$page->setMfExcludeHtmlSitemap(1);
55+
}
56+
57+
$pageCollection->save();
58+
59+
$this->moduleDataSetup->getConnection()->endSetup();
60+
}
61+
62+
/**
63+
* Revert function
64+
*/
65+
public function revert()
66+
{
67+
}
68+
69+
/**
70+
* {@inheritdoc}
71+
*/
72+
public function getAliases()
73+
{
74+
return [];
75+
}
76+
77+
/**
78+
* {@inheritdoc}
79+
*/
80+
public static function getDependencies()
81+
{
82+
return [];
83+
}
84+
}
85+

etc/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
<displaymore>1</displaymore>
5757
</blogcategorylinks>
5858
<additionallinks>
59-
<displaylinks>1</displaylinks>
59+
<displaylinks>0</displaylinks>
6060
<links>Enter/your/link/here/|(Title)</links>
6161
<title>Additional Pages</title>
6262
<position>60</position>

0 commit comments

Comments
 (0)