|
| 1 | +diff --git a/vendor/magento/module-catalog-permissions/Plugin/Wishlist/Block/Customer/ApplyWishlistItemsPermissions.php b/vendor/magento/module-catalog-permissions/Plugin/Wishlist/Block/Customer/ApplyWishlistItemsPermissions.php |
| 2 | +new file mode 100644 |
| 3 | +index 000000000000..8921a9a79062 |
| 4 | +--- /dev/null |
| 5 | ++++ b/vendor/magento/module-catalog-permissions/Plugin/Wishlist/Block/Customer/ApplyWishlistItemsPermissions.php |
| 6 | +@@ -0,0 +1,110 @@ |
| 7 | ++<?php |
| 8 | ++/** |
| 9 | ++ * ADOBE CONFIDENTIAL |
| 10 | ++ * |
| 11 | ++ * Copyright 2025 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\Wishlist\Block\Customer; |
| 26 | ++ |
| 27 | ++use Magento\CatalogPermissions\Model\Indexer\TableMaintainer; |
| 28 | ++use Magento\CatalogPermissions\App\ConfigInterface; |
| 29 | ++use Magento\CatalogPermissions\Helper\Data as Helper; |
| 30 | ++use Magento\CatalogPermissions\Model\Permission; |
| 31 | ++use Magento\Customer\Model\Session; |
| 32 | ++use Magento\Framework\DB\Select; |
| 33 | ++use Magento\Framework\Exception\LocalizedException; |
| 34 | ++use Magento\Framework\Exception\NoSuchEntityException; |
| 35 | ++use Magento\Store\Model\StoreManagerInterface; |
| 36 | ++use Magento\Wishlist\Block\Customer\Wishlist; |
| 37 | ++use Magento\Wishlist\Model\ResourceModel\Item\Collection; |
| 38 | ++use Magento\CatalogPermissions\Model\ResourceModel\Permission as ResourcePermission; |
| 39 | ++ |
| 40 | ++/** |
| 41 | ++ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) |
| 42 | ++ */ |
| 43 | ++class ApplyWishlistItemsPermissions |
| 44 | ++{ |
| 45 | ++ /** |
| 46 | ++ * @param Session $customerSession |
| 47 | ++ * @param ConfigInterface $permissionsConfig |
| 48 | ++ * @param ResourcePermission $resource |
| 49 | ++ * @param StoreManagerInterface $storeManager |
| 50 | ++ * @param TableMaintainer $tableMaintainer |
| 51 | ++ * @param Helper $helper |
| 52 | ++ */ |
| 53 | ++ public function __construct( |
| 54 | ++ private readonly Session $customerSession, |
| 55 | ++ private readonly ConfigInterface $permissionsConfig, |
| 56 | ++ private readonly ResourcePermission $resource, |
| 57 | ++ private readonly StoreManagerInterface $storeManager, |
| 58 | ++ private readonly TableMaintainer $tableMaintainer, |
| 59 | ++ private readonly Helper $helper |
| 60 | ++ ) { |
| 61 | ++ } |
| 62 | ++ |
| 63 | ++ /** |
| 64 | ++ * Apply category permissions on wishlist item collection |
| 65 | ++ * |
| 66 | ++ * @param Wishlist $subject |
| 67 | ++ * @param Collection $result |
| 68 | ++ * @return Collection |
| 69 | ++ * @throws LocalizedException |
| 70 | ++ * @throws NoSuchEntityException |
| 71 | ++ * @throws \Zend_Db_Select_Exception |
| 72 | ++ * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
| 73 | ++ */ |
| 74 | ++ public function afterGetWishlistItems(Wishlist $subject, Collection $result): Collection |
| 75 | ++ { |
| 76 | ++ if (!$this->permissionsConfig->isEnabled()) { |
| 77 | ++ return $result; |
| 78 | ++ } |
| 79 | ++ $customerGroupId = $this->customerSession->getCustomerGroupId(); |
| 80 | ++ $connection = $this->resource->getConnection(); |
| 81 | ++ |
| 82 | ++ $fromPart = $result->getSelect()->getPart(Select::FROM); |
| 83 | ++ |
| 84 | ++ $conditions[] = 'perm.product_id = main_table.product_id'; |
| 85 | ++ $conditions[] = $connection->quoteInto('perm.store_id = ?', $this->storeManager->getStore()->getId()); |
| 86 | ++ $conditions[] = $connection->quoteInto('perm.customer_group_id = ?', $customerGroupId); |
| 87 | ++ $joinConditions = join(' AND ', $conditions); |
| 88 | ++ $tableName = $this->tableMaintainer->resolveMainTableNameProduct($customerGroupId); |
| 89 | ++ |
| 90 | ++ if (!isset($fromPart['perm'])) { |
| 91 | ++ $result->getSelect()->joinLeft( |
| 92 | ++ ['perm' => $tableName], |
| 93 | ++ $joinConditions, |
| 94 | ++ ['grant_catalog_category_view', 'grant_catalog_product_price', 'grant_checkout_items'] |
| 95 | ++ ); |
| 96 | ++ } |
| 97 | ++ |
| 98 | ++ if (isset($fromPart['perm'])) { |
| 99 | ++ $fromPart['perm']['tableName'] = $tableName; |
| 100 | ++ $fromPart['perm']['joinCondition'] = $joinConditions; |
| 101 | ++ $result->getSelect()->setPart(Select::FROM, $fromPart); |
| 102 | ++ return $result; |
| 103 | ++ } |
| 104 | ++ |
| 105 | ++ if (!$this->helper->isAllowedCategoryView()) { |
| 106 | ++ $result->getSelect()->where('perm.grant_catalog_category_view = ?', Permission::PERMISSION_ALLOW); |
| 107 | ++ } else { |
| 108 | ++ $result->getSelect()->where( |
| 109 | ++ 'perm.grant_catalog_category_view != ?' . ' OR perm.grant_catalog_category_view IS NULL', |
| 110 | ++ Permission::PERMISSION_DENY |
| 111 | ++ ); |
| 112 | ++ } |
| 113 | ++ |
| 114 | ++ return $result; |
| 115 | ++ } |
| 116 | ++} |
| 117 | +diff --git a/vendor/magento/module-catalog-permissions/etc/frontend/di.xml b/vendor/magento/module-catalog-permissions/etc/frontend/di.xml |
| 118 | +index 4d0c9657903c..ca4a73da4784 100644 |
| 119 | +--- a/vendor/magento/module-catalog-permissions/etc/frontend/di.xml |
| 120 | ++++ b/vendor/magento/module-catalog-permissions/etc/frontend/di.xml |
| 121 | +@@ -17,4 +17,8 @@ |
| 122 | + <plugin name="update_cache_plugin" |
| 123 | + type="Magento\CatalogPermissions\Plugin\UpdateCachePlugin" /> |
| 124 | + </type> |
| 125 | ++ <type name="Magento\Wishlist\Block\Customer\Wishlist"> |
| 126 | ++ <plugin name="wishlist_items_apply_category_permissions" |
| 127 | ++ type="Magento\CatalogPermissions\Plugin\Wishlist\Block\Customer\ApplyWishlistItemsPermissions" /> |
| 128 | ++ </type> |
| 129 | + </config> |
| 130 | +diff --git a/vendor/magento/module-catalog-permissions/etc/graphql/events.xml b/vendor/magento/module-catalog-permissions/etc/graphql/events.xml |
| 131 | +new file mode 100644 |
| 132 | +index 000000000000..c1605a6f688f |
| 133 | +--- /dev/null |
| 134 | ++++ b/vendor/magento/module-catalog-permissions/etc/graphql/events.xml |
| 135 | +@@ -0,0 +1,23 @@ |
| 136 | ++<?xml version="1.0"?> |
| 137 | ++<!-- |
| 138 | ++/** |
| 139 | ++ * ADOBE CONFIDENTIAL |
| 140 | ++ * |
| 141 | ++ * Copyright 2025 Adobe |
| 142 | ++ * All Rights Reserved. |
| 143 | ++ * |
| 144 | ++ * NOTICE: All information contained herein is, and remains |
| 145 | ++ * the property of Adobe and its suppliers, if any. The intellectual |
| 146 | ++ * and technical concepts contained herein are proprietary to Adobe |
| 147 | ++ * and its suppliers and are protected by all applicable intellectual |
| 148 | ++ * property laws, including trade secret and copyright laws. |
| 149 | ++ * Dissemination of this information or reproduction of this material |
| 150 | ++ * is strictly forbidden unless prior written permission is obtained |
| 151 | ++ * from Adobe. |
| 152 | ++ */ |
| 153 | ++--> |
| 154 | ++<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> |
| 155 | ++ <event name="catalog_product_collection_load_after"> |
| 156 | ++ <observer name="magento_catalogpermissions" instance="Magento\CatalogPermissions\Observer\ApplyProductPermissionOnCollectionAfterLoadObserver"/> |
| 157 | ++ </event> |
| 158 | ++</config> |
| 159 | +diff --git a/vendor/magento/module-multiple-wishlist/Helper/Data.php b/vendor/magento/module-multiple-wishlist/Helper/Data.php |
| 160 | +index 9dcb51edf734..3611eceb794e 100644 |
| 161 | +--- a/vendor/magento/module-multiple-wishlist/Helper/Data.php |
| 162 | ++++ b/vendor/magento/module-multiple-wishlist/Helper/Data.php |
| 163 | +@@ -242,7 +242,7 @@ public function getWishlistItemCount(Wishlist $wishlist) |
| 164 | + ) { |
| 165 | + $count = $collection->getItemsQty(); |
| 166 | + } else { |
| 167 | +- $count = $collection->getSize(); |
| 168 | ++ $count = count($collection->getItems()); |
| 169 | + } |
| 170 | + return $count; |
| 171 | + } |
0 commit comments