Skip to content

Commit 03247f2

Browse files
committed
Exclude Page
1 parent 5849497 commit 03247f2

File tree

2 files changed

+95
-1
lines changed

2 files changed

+95
-1
lines changed

Setup/Patch/Data/PageToExclude.php

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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\Eav\Setup\EavSetupFactory;
13+
use Magento\Framework\Setup\ModuleDataSetupInterface;
14+
use Magento\Framework\Setup\Patch\DataPatchInterface;
15+
use Magento\Framework\Setup\Patch\PatchRevertableInterface;
16+
17+
class PageToExclude implements DataPatchInterface, PatchRevertableInterface
18+
{
19+
20+
/**
21+
* @var ModuleDataSetupInterface
22+
*/
23+
private $moduleDataSetup;
24+
25+
/**
26+
* @var EavSetupFactory
27+
*/
28+
private $eavSetupFactory;
29+
30+
/**
31+
* @var PageCollectionFactory
32+
*/
33+
private $pageCollectionFactory;
34+
35+
/**
36+
* @param ModuleDataSetupInterface $moduleDataSetup
37+
* @param EavSetupFactory $eavSetupFactory
38+
* @param PageCollectionFactory $pageCollectionFactory
39+
*/
40+
public function __construct(
41+
ModuleDataSetupInterface $moduleDataSetup,
42+
EavSetupFactory $eavSetupFactory,
43+
PageCollectionFactory $pageCollectionFactory
44+
)
45+
{
46+
$this->moduleDataSetup = $moduleDataSetup;
47+
$this->eavSetupFactory = $eavSetupFactory;
48+
$this->pageCollectionFactory = $pageCollectionFactory;
49+
}
50+
51+
/**
52+
* @return void
53+
*/
54+
public function apply()
55+
{
56+
$this->moduleDataSetup->getConnection()->startSetup();
57+
58+
$pageCollection = $this->pageCollectionFactory->create();
59+
60+
$pageCollection->addFieldToFilter('identifier', ['in' => ['no-route', 'home', 'enable-cookies']]);
61+
62+
foreach ($pageCollection as $page) {
63+
$page->setMfExcludeHtmlSitemap(1);
64+
}
65+
66+
$pageCollection->save();
67+
68+
$this->moduleDataSetup->getConnection()->endSetup();
69+
}
70+
71+
/**
72+
* Revert function
73+
*/
74+
public function revert()
75+
{
76+
}
77+
78+
/**
79+
* {@inheritdoc}
80+
*/
81+
public function getAliases()
82+
{
83+
return [];
84+
}
85+
86+
/**
87+
* {@inheritdoc}
88+
*/
89+
public static function getDependencies()
90+
{
91+
return [];
92+
}
93+
}
94+

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)