diff --git a/vendor/magento/module-catalog-permissions/Plugin/Sitemap/Model/ResourceModel/Catalog/CategoryPlugin.php b/vendor/magento/module-catalog-permissions/Plugin/Sitemap/Model/ResourceModel/Catalog/CategoryPlugin.php
new file mode 100644
index 000000000000..8c9a8c78d63c
--- /dev/null
+++ b/vendor/magento/module-catalog-permissions/Plugin/Sitemap/Model/ResourceModel/Catalog/CategoryPlugin.php
@@ -0,0 +1,85 @@
+config = $config;
+ $this->permissionIndex = $permissionIndex;
+ }
+
+ /**
+ * Allow only products from public shared catalog assigned to allowed categories
+ *
+ * @param CategorySelectBuilder $subject
+ * @param Select $select
+ * @param string $mainTableName
+ * @param string $idField
+ * @param StoreInterface $store
+ * @param string $path
+ * @return Select
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function afterExecute(
+ CategorySelectBuilder $subject,
+ Select $select,
+ string $mainTableName,
+ string $idField,
+ StoreInterface $store,
+ string $path
+ ): Select {
+ if (!$this->config->isEnabled($store->getId())) {
+ return $select;
+ }
+
+ $restrictedCategoryIds = $this->permissionIndex->getRestrictedCategoryIds(
+ Group::NOT_LOGGED_IN_ID,
+ $store->getWebsiteId()
+ );
+ if (count($restrictedCategoryIds)) {
+ $select->where('e.entity_id NOT IN (?)', $restrictedCategoryIds);
+ }
+
+ return $select;
+ }
+}
diff --git a/vendor/magento/module-catalog-permissions/Plugin/Sitemap/Model/ResourceModel/Catalog/ProductPlugin.php b/vendor/magento/module-catalog-permissions/Plugin/Sitemap/Model/ResourceModel/Catalog/ProductPlugin.php
new file mode 100644
index 000000000000..a9bd546e4a9d
--- /dev/null
+++ b/vendor/magento/module-catalog-permissions/Plugin/Sitemap/Model/ResourceModel/Catalog/ProductPlugin.php
@@ -0,0 +1,103 @@
+config = $config;
+ $this->permissionIndex = $permissionIndex;
+ }
+
+ /**
+ * Allow only products from public shared catalog assigned to allowed categories
+ *
+ * @param ProductSelectBuilder $subject
+ * @param Select $select
+ * @param string $mainTableName
+ * @param string $idField
+ * @param string $linkField
+ * @param StoreInterface $store
+ * @return Select
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function afterExecute(
+ ProductSelectBuilder $subject,
+ Select $select,
+ string $mainTableName,
+ string $idField,
+ string $linkField,
+ StoreInterface $store
+ ): Select {
+ if (!$this->config->isEnabled($store->getId())) {
+ return $select;
+ }
+
+ $restrictedCategoryIds = $this->permissionIndex->getRestrictedCategoryIds(
+ Group::NOT_LOGGED_IN_ID,
+ $store->getWebsiteId()
+ );
+ if (count($restrictedCategoryIds)) {
+ $select->joinLeft(
+ ['cp' => $select->getConnection()->getTableName('catalog_category_product')],
+ 'cp.product_id = e.entity_id',
+ []
+ )->where(
+ 'cp.category_id NOT IN (?)',
+ $restrictedCategoryIds
+ );
+ $select->joinLeft(
+ ['perm' => $select->getConnection()->getTableName('magento_catalogpermissions_index_product')],
+ 'perm.product_id = e.entity_id',
+ []
+ )->where(
+ '((perm.grant_catalog_category_view != ' . Permission::PERMISSION_DENY . '
+ AND perm.customer_group_id = ' . Group::NOT_LOGGED_IN_ID . '
+ AND perm.store_id in (?)) OR perm.grant_catalog_category_view IS NULL)',
+ [$store->getId()]
+ );
+ }
+
+ return $select;
+ }
+}
diff --git a/vendor/magento/module-catalog-permissions/etc/di.xml b/vendor/magento/module-catalog-permissions/etc/di.xml
index 242c242eec23..f3ed70b02854 100644
--- a/vendor/magento/module-catalog-permissions/etc/di.xml
+++ b/vendor/magento/module-catalog-permissions/etc/di.xml
@@ -74,4 +74,12 @@
+
+
+
+
+
+
diff --git a/vendor/magento/module-catalog-permissions/etc/module.xml b/vendor/magento/module-catalog-permissions/etc/module.xml
index 438774a51137..adf4fbd42aed 100644
--- a/vendor/magento/module-catalog-permissions/etc/module.xml
+++ b/vendor/magento/module-catalog-permissions/etc/module.xml
@@ -13,6 +13,7 @@
+