3030use Magento \CatalogInventory \Helper \Stock ;
3131use Magento \Cms \Model \Page ;
3232use Magento \Cms \Model \ResourceModel \Page \Collection as PageCollection ;
33+ use Magento \Framework \Data \Tree \Node \Collection as TreeCollection ;
3334use Magento \Framework \Exception \NoSuchEntityException ;
3435use Magento \Framework \View \Element \Template ;
3536use Magento \Framework \View \Element \Template \Context ;
@@ -129,6 +130,7 @@ public function __construct(
129130
130131 /**
131132 * Get product collection
133+ *
132134 * @return mixed
133135 */
134136 public function getProductCollection ()
@@ -150,15 +152,16 @@ public function getProductCollection()
150152
151153 /**
152154 * Get category collection
153- * @return \Magento\Framework\Data\Tree\Node\Collection
155+ *
156+ * @return TreeCollection
154157 */
155158 public function getCategoryCollection ()
156159 {
157160 return $ this ->_categoryHelper ->getStoreCategories (false , true );
158161 }
159162
160163 /**
161- * @param $categoryId
164+ * @param int $categoryId
162165 *
163166 * @return string
164167 * @throws NoSuchEntityException
@@ -178,7 +181,7 @@ public function getPageCollection()
178181 {
179182 $ excludePages = $ this ->_helper ->getExcludePageListing ();
180183 $ pageCollection = $ this ->pageCollection ->addFieldToFilter ('is_active ' , Page::STATUS_ENABLED )
181- ->addStoreFilter ($ this ->_storeManager ->getStore ());
184+ ->addStoreFilter ($ this ->_storeManager ->getStore ()-> getId () );
182185
183186 if ($ this ->_helper ->isEnableExcludePage () && !empty ($ excludePages )) {
184187 $ pageCollection ->addFieldToFilter ('identifier ' , [
@@ -191,6 +194,7 @@ public function getPageCollection()
191194
192195 /**
193196 * Get excluded pages
197+ *
194198 * @return array
195199 */
196200 public function getExcludedPages ()
@@ -200,6 +204,7 @@ public function getExcludedPages()
200204
201205 /**
202206 * Get addition link collection
207+ *
203208 * @return mixed
204209 */
205210 public function getAdditionLinksCollection ()
@@ -220,8 +225,8 @@ public function getAdditionLinksCollection()
220225 /**
221226 * Render link element
222227 *
223- * @param $link
224- * @param $title
228+ * @param string $link
229+ * @param string $title
225230 *
226231 * @return string
227232 */
@@ -230,11 +235,12 @@ public function renderLinkElement($link, $title)
230235 return '<li><a href=" ' . $ link . '"> ' . __ ($ title ) . '</a></li> ' ;
231236 }
232237
238+ // phpcs:disable Generic.Metrics.NestingLevel
233239 /**
234- * @param $section
235- * @param $config
236- * @param $title
237- * @param $collection
240+ * @param string $section
241+ * @param bool $config
242+ * @param string $title
243+ * @param Object $collection
238244 *
239245 * @return string
240246 * @throws NoSuchEntityException
@@ -250,15 +256,25 @@ public function renderSection($section, $config, $title, $collection)
250256 foreach ($ collection as $ key => $ item ) {
251257 switch ($ section ) {
252258 case 'category ' :
253- $ html .= $ this ->renderLinkElement ($ this ->getCategoryUrl ($ item ->getId ()), $ item ->getName ());
259+ $ category = $ this ->categoryRepository ->get ($ item ->getId ());
260+ if (!$ category ->getData ('mp_exclude_sitemap ' )) {
261+ $ html .= $ this ->renderLinkElement (
262+ $ this ->getCategoryUrl ($ item ->getId ()),
263+ $ item ->getName ()
264+ );
265+ }
254266 break ;
255267 case 'page ' :
256- if (in_array ($ item ->getIdentifier (), $ this ->getExcludedPages ())) {
268+ if (in_array ($ item ->getIdentifier (), $ this ->getExcludedPages ())
269+ || $ item ->getData ('mp_exclude_sitemap ' )) {
257270 continue 2 ;
258271 }
259272 $ html .= $ this ->renderLinkElement ($ this ->getUrl ($ item ->getIdentifier ()), $ item ->getTitle ());
260273 break ;
261274 case 'product ' :
275+ if ($ item ->getData ('mp_exclude_sitemap ' )) {
276+ continue 2 ;
277+ }
262278 $ html .= $ this ->renderLinkElement ($ this ->getUrl ($ item ->getProductUrl ()), $ item ->getName ());
263279 break ;
264280 case 'link ' :
@@ -311,6 +327,7 @@ public function renderHtmlSitemap()
311327
312328 /**
313329 * Is enable html site map
330+ *
314331 * @return mixed
315332 */
316333 public function isEnableHtmlSitemap ()
0 commit comments