|
| 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..af1ccf507d7a |
| 4 | +--- /dev/null |
| 5 | ++++ b/vendor/magento/module-catalog-permissions/Plugin/Sitemap/Model/ResourceModel/Catalog/CategoryPlugin.php |
| 6 | +@@ -0,0 +1,75 @@ |
| 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 | ++ /** |
| 38 | ++ * @param Config $config |
| 39 | ++ * @param Index $permissionIndex |
| 40 | ++ */ |
| 41 | ++ public function __construct( |
| 42 | ++ private readonly Config $config, |
| 43 | ++ private readonly Index $permissionIndex |
| 44 | ++ ) { |
| 45 | ++ } |
| 46 | ++ |
| 47 | ++ /** |
| 48 | ++ * Allow only products from public shared catalog assigned to allowed categories |
| 49 | ++ * |
| 50 | ++ * @param CategorySelectBuilder $subject |
| 51 | ++ * @param Select $select |
| 52 | ++ * @param string $mainTableName |
| 53 | ++ * @param string $idField |
| 54 | ++ * @param StoreInterface $store |
| 55 | ++ * @param string $path |
| 56 | ++ * @return Select |
| 57 | ++ * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
| 58 | ++ */ |
| 59 | ++ public function afterExecute( |
| 60 | ++ CategorySelectBuilder $subject, |
| 61 | ++ Select $select, |
| 62 | ++ string $mainTableName, |
| 63 | ++ string $idField, |
| 64 | ++ StoreInterface $store, |
| 65 | ++ string $path |
| 66 | ++ ): Select { |
| 67 | ++ if (!$this->config->isEnabled($store->getId())) { |
| 68 | ++ return $select; |
| 69 | ++ } |
| 70 | ++ |
| 71 | ++ $restrictedCategoryIds = $this->permissionIndex->getRestrictedCategoryIds( |
| 72 | ++ Group::NOT_LOGGED_IN_ID, |
| 73 | ++ $store->getWebsiteId() |
| 74 | ++ ); |
| 75 | ++ if (count($restrictedCategoryIds)) { |
| 76 | ++ $select->where('e.entity_id NOT IN (?)', $restrictedCategoryIds); |
| 77 | ++ } |
| 78 | ++ |
| 79 | ++ return $select; |
| 80 | ++ } |
| 81 | ++} |
| 82 | +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 |
| 83 | +new file mode 100644 |
| 84 | +index 000000000000..f1df4e384eeb |
| 85 | +--- /dev/null |
| 86 | ++++ b/vendor/magento/module-catalog-permissions/Plugin/Sitemap/Model/ResourceModel/Catalog/ProductPlugin.php |
| 87 | +@@ -0,0 +1,92 @@ |
| 88 | ++<?php |
| 89 | ++/** |
| 90 | ++ * ADOBE CONFIDENTIAL |
| 91 | ++ * |
| 92 | ++ * Copyright 2023 Adobe |
| 93 | ++ * All Rights Reserved. |
| 94 | ++ * |
| 95 | ++ * NOTICE: All information contained herein is, and remains |
| 96 | ++ * the property of Adobe and its suppliers, if any. The intellectual |
| 97 | ++ * and technical concepts contained herein are proprietary to Adobe |
| 98 | ++ * and its suppliers and are protected by all applicable intellectual |
| 99 | ++ * property laws, including trade secret and copyright laws. |
| 100 | ++ * Dissemination of this information or reproduction of this material |
| 101 | ++ * is strictly forbidden unless prior written permission is obtained |
| 102 | ++ * from Adobe. |
| 103 | ++ */ |
| 104 | ++declare(strict_types=1); |
| 105 | ++ |
| 106 | ++namespace Magento\CatalogPermissions\Plugin\Sitemap\Model\ResourceModel\Catalog; |
| 107 | ++ |
| 108 | ++use Magento\CatalogPermissions\App\Config; |
| 109 | ++use Magento\CatalogPermissions\Model\Permission; |
| 110 | ++use Magento\CatalogPermissions\Model\Permission\Index; |
| 111 | ++use Magento\Customer\Model\Group; |
| 112 | ++use Magento\Framework\DB\Select; |
| 113 | ++use Magento\Sitemap\Model\ResourceModel\Catalog\ProductSelectBuilder; |
| 114 | ++use Magento\Store\Api\Data\StoreInterface; |
| 115 | ++ |
| 116 | ++class ProductPlugin |
| 117 | ++{ |
| 118 | ++ /** |
| 119 | ++ * @param Config $config |
| 120 | ++ * @param Index $permissionIndex |
| 121 | ++ */ |
| 122 | ++ public function __construct( |
| 123 | ++ private Config $config, |
| 124 | ++ private readonly Index $permissionIndex |
| 125 | ++ ) { |
| 126 | ++ } |
| 127 | ++ |
| 128 | ++ /** |
| 129 | ++ * Allow only products from public shared catalog assigned to allowed categories |
| 130 | ++ * |
| 131 | ++ * @param ProductSelectBuilder $subject |
| 132 | ++ * @param Select $select |
| 133 | ++ * @param string $mainTableName |
| 134 | ++ * @param string $idField |
| 135 | ++ * @param string $linkField |
| 136 | ++ * @param StoreInterface $store |
| 137 | ++ * @return Select |
| 138 | ++ * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
| 139 | ++ */ |
| 140 | ++ public function afterExecute( |
| 141 | ++ ProductSelectBuilder $subject, |
| 142 | ++ Select $select, |
| 143 | ++ string $mainTableName, |
| 144 | ++ string $idField, |
| 145 | ++ string $linkField, |
| 146 | ++ StoreInterface $store |
| 147 | ++ ): Select { |
| 148 | ++ if (!$this->config->isEnabled($store->getId())) { |
| 149 | ++ return $select; |
| 150 | ++ } |
| 151 | ++ |
| 152 | ++ $restrictedCategoryIds = $this->permissionIndex->getRestrictedCategoryIds( |
| 153 | ++ Group::NOT_LOGGED_IN_ID, |
| 154 | ++ $store->getWebsiteId() |
| 155 | ++ ); |
| 156 | ++ if (count($restrictedCategoryIds)) { |
| 157 | ++ $select->joinLeft( |
| 158 | ++ ['cp' => $select->getConnection()->getTableName('catalog_category_product')], |
| 159 | ++ 'cp.product_id = e.entity_id', |
| 160 | ++ [] |
| 161 | ++ )->where( |
| 162 | ++ 'cp.category_id NOT IN (?)', |
| 163 | ++ $restrictedCategoryIds |
| 164 | ++ ); |
| 165 | ++ $select->joinLeft( |
| 166 | ++ ['perm' => $select->getConnection()->getTableName('magento_catalogpermissions_index_product')], |
| 167 | ++ 'perm.product_id = e.entity_id', |
| 168 | ++ [] |
| 169 | ++ )->where( |
| 170 | ++ '((perm.grant_catalog_category_view != ' . Permission::PERMISSION_DENY . ' |
| 171 | ++ AND perm.customer_group_id = ' . Group::NOT_LOGGED_IN_ID . ' |
| 172 | ++ AND perm.store_id in (?)) OR perm.grant_catalog_category_view IS NULL)', |
| 173 | ++ [$store->getId()] |
| 174 | ++ ); |
| 175 | ++ } |
| 176 | ++ |
| 177 | ++ return $select; |
| 178 | ++ } |
| 179 | ++} |
| 180 | +diff --git a/vendor/magento/module-catalog-permissions/etc/di.xml b/vendor/magento/module-catalog-permissions/etc/di.xml |
| 181 | +index f1a96cd977fa..390b89b33806 100644 |
| 182 | +--- a/vendor/magento/module-catalog-permissions/etc/di.xml |
| 183 | ++++ b/vendor/magento/module-catalog-permissions/etc/di.xml |
| 184 | +@@ -99,4 +99,12 @@ |
| 185 | + <plugin name="check_catalog_permission_after_get_section_data" |
| 186 | + type="Magento\CatalogPermissions\Plugin\Sales\CustomerData\CheckCatalogPermissionAfterLastOrderedItemsPlugin" /> |
| 187 | + </type> |
| 188 | ++ <type name="Magento\Sitemap\Model\ResourceModel\Catalog\ProductSelectBuilder"> |
| 189 | ++ <plugin name="generate_sitemap_with_allowed_products_permissions" |
| 190 | ++ type="Magento\CatalogPermissions\Plugin\Sitemap\Model\ResourceModel\Catalog\ProductPlugin" /> |
| 191 | ++ </type> |
| 192 | ++ <type name="Magento\Sitemap\Model\ResourceModel\Catalog\CategorySelectBuilder"> |
| 193 | ++ <plugin name="generate_sitemap_with_allowed_categories_permissions" |
| 194 | ++ type="Magento\CatalogPermissions\Plugin\Sitemap\Model\ResourceModel\Catalog\CategoryPlugin" /> |
| 195 | ++ </type> |
| 196 | + </config> |
| 197 | + |
0 commit comments