|
| 1 | +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 |
| 2 | +new file mode 100644 |
| 3 | +index 000000000000..8c9a8c78d63c |
| 4 | +--- /dev/null |
| 5 | ++++ b/vendor/magento/module-catalog-permissions/Plugin/Sitemap/Model/ResourceModel/Catalog/CategoryPlugin.php |
| 6 | +@@ -0,0 +1,85 @@ |
| 7 | ++<?php |
| 8 | ++/** |
| 9 | ++ * ADOBE CONFIDENTIAL |
| 10 | ++ * |
| 11 | ++ * Copyright 2023 Adobe |
| 12 | ++ * All Rights Reserved. |
| 13 | ++ * |
| 14 | ++ * NOTICE: All information contained herein is, and remains |
| 15 | ++ * the property of Adobe and its suppliers, if any. The intellectual |
| 16 | ++ * and technical concepts contained herein are proprietary to Adobe |
| 17 | ++ * and its suppliers and are protected by all applicable intellectual |
| 18 | ++ * property laws, including trade secret and copyright laws. |
| 19 | ++ * Dissemination of this information or reproduction of this material |
| 20 | ++ * is strictly forbidden unless prior written permission is obtained |
| 21 | ++ * from Adobe. |
| 22 | ++ */ |
| 23 | ++declare(strict_types=1); |
| 24 | ++ |
| 25 | ++namespace Magento\CatalogPermissions\Plugin\Sitemap\Model\ResourceModel\Catalog; |
| 26 | ++ |
| 27 | ++use Magento\CatalogPermissions\App\Config; |
| 28 | ++use Magento\CatalogPermissions\Model\Permission\Index; |
| 29 | ++use Magento\Customer\Model\Group; |
| 30 | ++use Magento\Framework\DB\Select; |
| 31 | ++use Magento\Sitemap\Model\ResourceModel\Catalog\CategorySelectBuilder; |
| 32 | ++use Magento\Store\Api\Data\StoreInterface; |
| 33 | ++ |
| 34 | ++class CategoryPlugin |
| 35 | ++{ |
| 36 | ++ /** |
| 37 | ++ * @var Config |
| 38 | ++ */ |
| 39 | ++ private $config; |
| 40 | ++ |
| 41 | ++ /** |
| 42 | ++ * @var Index |
| 43 | ++ */ |
| 44 | ++ private $permissionIndex; |
| 45 | ++ |
| 46 | ++ /** |
| 47 | ++ * Constructor. |
| 48 | ++ * |
| 49 | ++ * @param Config $config |
| 50 | ++ * @param Index $permissionIndex |
| 51 | ++ */ |
| 52 | ++ public function __construct(Config $config, Index $permissionIndex) { |
| 53 | ++ $this->config = $config; |
| 54 | ++ $this->permissionIndex = $permissionIndex; |
| 55 | ++ } |
| 56 | ++ |
| 57 | ++ /** |
| 58 | ++ * Allow only products from public shared catalog assigned to allowed categories |
| 59 | ++ * |
| 60 | ++ * @param CategorySelectBuilder $subject |
| 61 | ++ * @param Select $select |
| 62 | ++ * @param string $mainTableName |
| 63 | ++ * @param string $idField |
| 64 | ++ * @param StoreInterface $store |
| 65 | ++ * @param string $path |
| 66 | ++ * @return Select |
| 67 | ++ * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
| 68 | ++ */ |
| 69 | ++ public function afterExecute( |
| 70 | ++ CategorySelectBuilder $subject, |
| 71 | ++ Select $select, |
| 72 | ++ string $mainTableName, |
| 73 | ++ string $idField, |
| 74 | ++ StoreInterface $store, |
| 75 | ++ string $path |
| 76 | ++ ): Select { |
| 77 | ++ if (!$this->config->isEnabled($store->getId())) { |
| 78 | ++ return $select; |
| 79 | ++ } |
| 80 | ++ |
| 81 | ++ $restrictedCategoryIds = $this->permissionIndex->getRestrictedCategoryIds( |
| 82 | ++ Group::NOT_LOGGED_IN_ID, |
| 83 | ++ $store->getWebsiteId() |
| 84 | ++ ); |
| 85 | ++ if (count($restrictedCategoryIds)) { |
| 86 | ++ $select->where('e.entity_id NOT IN (?)', $restrictedCategoryIds); |
| 87 | ++ } |
| 88 | ++ |
| 89 | ++ return $select; |
| 90 | ++ } |
| 91 | ++} |
| 92 | +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 |
| 93 | +new file mode 100644 |
| 94 | +index 000000000000..a9bd546e4a9d |
| 95 | +--- /dev/null |
| 96 | ++++ b/vendor/magento/module-catalog-permissions/Plugin/Sitemap/Model/ResourceModel/Catalog/ProductPlugin.php |
| 97 | +@@ -0,0 +1,103 @@ |
| 98 | ++<?php |
| 99 | ++/** |
| 100 | ++ * ADOBE CONFIDENTIAL |
| 101 | ++ * |
| 102 | ++ * Copyright 2023 Adobe |
| 103 | ++ * All Rights Reserved. |
| 104 | ++ * |
| 105 | ++ * NOTICE: All information contained herein is, and remains |
| 106 | ++ * the property of Adobe and its suppliers, if any. The intellectual |
| 107 | ++ * and technical concepts contained herein are proprietary to Adobe |
| 108 | ++ * and its suppliers and are protected by all applicable intellectual |
| 109 | ++ * property laws, including trade secret and copyright laws. |
| 110 | ++ * Dissemination of this information or reproduction of this material |
| 111 | ++ * is strictly forbidden unless prior written permission is obtained |
| 112 | ++ * from Adobe. |
| 113 | ++ */ |
| 114 | ++declare(strict_types=1); |
| 115 | ++ |
| 116 | ++namespace Magento\CatalogPermissions\Plugin\Sitemap\Model\ResourceModel\Catalog; |
| 117 | ++ |
| 118 | ++use Magento\CatalogPermissions\App\Config; |
| 119 | ++use Magento\CatalogPermissions\Model\Permission; |
| 120 | ++use Magento\CatalogPermissions\Model\Permission\Index; |
| 121 | ++use Magento\Customer\Model\Group; |
| 122 | ++use Magento\Framework\DB\Select; |
| 123 | ++use Magento\Sitemap\Model\ResourceModel\Catalog\ProductSelectBuilder; |
| 124 | ++use Magento\Store\Api\Data\StoreInterface; |
| 125 | ++ |
| 126 | ++class ProductPlugin |
| 127 | ++{ |
| 128 | ++ /** |
| 129 | ++ * @var Config |
| 130 | ++ */ |
| 131 | ++ private $config; |
| 132 | ++ |
| 133 | ++ /** |
| 134 | ++ * @var Index |
| 135 | ++ */ |
| 136 | ++ private $permissionIndex; |
| 137 | ++ |
| 138 | ++ /** |
| 139 | ++ * Constructor. |
| 140 | ++ * |
| 141 | ++ * @param Config $config |
| 142 | ++ * @param Index $permissionIndex |
| 143 | ++ */ |
| 144 | ++ public function __construct(Config $config, Index $permissionIndex) { |
| 145 | ++ $this->config = $config; |
| 146 | ++ $this->permissionIndex = $permissionIndex; |
| 147 | ++ } |
| 148 | ++ |
| 149 | ++ /** |
| 150 | ++ * Allow only products from public shared catalog assigned to allowed categories |
| 151 | ++ * |
| 152 | ++ * @param ProductSelectBuilder $subject |
| 153 | ++ * @param Select $select |
| 154 | ++ * @param string $mainTableName |
| 155 | ++ * @param string $idField |
| 156 | ++ * @param string $linkField |
| 157 | ++ * @param StoreInterface $store |
| 158 | ++ * @return Select |
| 159 | ++ * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
| 160 | ++ */ |
| 161 | ++ public function afterExecute( |
| 162 | ++ ProductSelectBuilder $subject, |
| 163 | ++ Select $select, |
| 164 | ++ string $mainTableName, |
| 165 | ++ string $idField, |
| 166 | ++ string $linkField, |
| 167 | ++ StoreInterface $store |
| 168 | ++ ): Select { |
| 169 | ++ if (!$this->config->isEnabled($store->getId())) { |
| 170 | ++ return $select; |
| 171 | ++ } |
| 172 | ++ |
| 173 | ++ $restrictedCategoryIds = $this->permissionIndex->getRestrictedCategoryIds( |
| 174 | ++ Group::NOT_LOGGED_IN_ID, |
| 175 | ++ $store->getWebsiteId() |
| 176 | ++ ); |
| 177 | ++ if (count($restrictedCategoryIds)) { |
| 178 | ++ $select->joinLeft( |
| 179 | ++ ['cp' => $select->getConnection()->getTableName('catalog_category_product')], |
| 180 | ++ 'cp.product_id = e.entity_id', |
| 181 | ++ [] |
| 182 | ++ )->where( |
| 183 | ++ 'cp.category_id NOT IN (?)', |
| 184 | ++ $restrictedCategoryIds |
| 185 | ++ ); |
| 186 | ++ $select->joinLeft( |
| 187 | ++ ['perm' => $select->getConnection()->getTableName('magento_catalogpermissions_index_product')], |
| 188 | ++ 'perm.product_id = e.entity_id', |
| 189 | ++ [] |
| 190 | ++ )->where( |
| 191 | ++ '((perm.grant_catalog_category_view != ' . Permission::PERMISSION_DENY . ' |
| 192 | ++ AND perm.customer_group_id = ' . Group::NOT_LOGGED_IN_ID . ' |
| 193 | ++ AND perm.store_id in (?)) OR perm.grant_catalog_category_view IS NULL)', |
| 194 | ++ [$store->getId()] |
| 195 | ++ ); |
| 196 | ++ } |
| 197 | ++ |
| 198 | ++ return $select; |
| 199 | ++ } |
| 200 | ++} |
| 201 | +diff --git a/vendor/magento/module-catalog-permissions/etc/di.xml b/vendor/magento/module-catalog-permissions/etc/di.xml |
| 202 | +index 242c242eec23..f3ed70b02854 100644 |
| 203 | +--- a/vendor/magento/module-catalog-permissions/etc/di.xml |
| 204 | ++++ b/vendor/magento/module-catalog-permissions/etc/di.xml |
| 205 | +@@ -74,4 +74,12 @@ |
| 206 | + <type name="Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection"> |
| 207 | + <plugin name="can_show_price_in_layered_navigation_plugin" type="Magento\CatalogPermissions\Plugin\CatalogSearch\Model\ResourceModel\Fulltext\Collection" /> |
| 208 | + </type> |
| 209 | ++ <type name="Magento\Sitemap\Model\ResourceModel\Catalog\ProductSelectBuilder"> |
| 210 | ++ <plugin name="generate_sitemap_with_allowed_products_permissions" |
| 211 | ++ type="Magento\CatalogPermissions\Plugin\Sitemap\Model\ResourceModel\Catalog\ProductPlugin" /> |
| 212 | ++ </type> |
| 213 | ++ <type name="Magento\Sitemap\Model\ResourceModel\Catalog\CategorySelectBuilder"> |
| 214 | ++ <plugin name="generate_sitemap_with_allowed_categories_permissions" |
| 215 | ++ type="Magento\CatalogPermissions\Plugin\Sitemap\Model\ResourceModel\Catalog\CategoryPlugin" /> |
| 216 | ++ </type> |
| 217 | + </config> |
| 218 | +diff --git a/vendor/magento/module-catalog-permissions/etc/module.xml b/vendor/magento/module-catalog-permissions/etc/module.xml |
| 219 | +index 438774a51137..adf4fbd42aed 100644 |
| 220 | +--- a/vendor/magento/module-catalog-permissions/etc/module.xml |
| 221 | ++++ b/vendor/magento/module-catalog-permissions/etc/module.xml |
| 222 | +@@ -13,6 +13,7 @@ |
| 223 | + <module name="Magento_CatalogSearch"/> |
| 224 | + <module name="Magento_Quote"/> |
| 225 | + <module name="Magento_Checkout"/> |
| 226 | ++ <module name="Magento_Sitemap" /> |
| 227 | + <module name="Magento_WebsiteRestriction"/> |
| 228 | + <module name="Magento_Ui"/> |
| 229 | + </sequence> |
0 commit comments