Skip to content

Commit 6bab21a

Browse files
Merge pull request #153 from magento-commerce/1.1.48-release
1.1.48 Release
2 parents 1b5000a + 4fd5444 commit 6bab21a

26 files changed

+6054
-15
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "magento/quality-patches",
33
"description": "Provides quality patches for AdobeCommerce & Magento OpenSource",
44
"type": "magento2-component",
5-
"version": "1.1.47",
5+
"version": "1.1.48",
66
"license": "proprietary",
77
"repositories": {
88
"repo": {

patches-info.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

patches/commerce/ACSD-56472_2.4.5-p2.patch

Lines changed: 422 additions & 0 deletions
Large diffs are not rendered by default.

patches/commerce/ACSD-56635_2.4.6-p3.patch

Lines changed: 381 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
diff --git a/vendor/magento/module-company/Plugin/Company/CollectionFilter.php b/vendor/magento/module-company/Plugin/Company/CollectionFilter.php
2+
new file mode 100644
3+
index 000000000000..cd5d83a1799f
4+
--- /dev/null
5+
+++ b/vendor/magento/module-company/Plugin/Company/CollectionFilter.php
6+
@@ -0,0 +1,124 @@
7+
+<?php
8+
+/************************************************************************
9+
+ *
10+
+ * ADOBE CONFIDENTIAL
11+
+ * ___________________
12+
+ *
13+
+ * Copyright 2024 Adobe
14+
+ * All Rights Reserved.
15+
+ *
16+
+ * NOTICE: All information contained herein is, and remains
17+
+ * the property of Adobe and its suppliers, if any. The intellectual
18+
+ * and technical concepts contained herein are proprietary to Adobe
19+
+ * and its suppliers and are protected by all applicable intellectual
20+
+ * property laws, including trade secret and copyright laws.
21+
+ * Dissemination of this information or reproduction of this material
22+
+ * is strictly forbidden unless prior written permission is obtained
23+
+ * from Adobe.
24+
+ * ************************************************************************
25+
+ */
26+
+declare(strict_types=1);
27+
+
28+
+namespace Magento\Company\Plugin\Company;
29+
+
30+
+use Magento\Authorization\Model\Role;
31+
+use Magento\Backend\Model\Auth\Session;
32+
+use Magento\Company\Model\ResourceModel\Company\Collection;
33+
+use Magento\Framework\App\RequestInterface;
34+
+use Magento\Framework\DB\Select;
35+
+use Magento\Framework\Exception\LocalizedException;
36+
+
37+
+/**
38+
+ * @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
39+
+ */
40+
+class CollectionFilter
41+
+{
42+
+ private const FILTERED_FLAG_NAME = 'admin_gws_filtered_b2b';
43+
+
44+
+ /**
45+
+ * @param Session $backendAuthSession
46+
+ * @param RequestInterface $request
47+
+ */
48+
+ public function __construct(
49+
+ private readonly Session $backendAuthSession,
50+
+ private readonly RequestInterface $request
51+
+ ) {
52+
+ }
53+
+
54+
+ /**
55+
+ * Adds only allowed websites to company filter.
56+
+ *
57+
+ * @param Collection $collection
58+
+ * @param bool $printQuery
59+
+ * @param bool $logQuery
60+
+ * @return array
61+
+ * @throws LocalizedException
62+
+ * @throws \Zend_Db_Select_Exception
63+
+ */
64+
+ public function beforeLoadWithFilter(
65+
+ Collection $collection,
66+
+ bool $printQuery = false,
67+
+ bool $logQuery = false
68+
+ ): array {
69+
+ $this->filterCollection($collection);
70+
+
71+
+ return [$printQuery, $logQuery];
72+
+ }
73+
+
74+
+ /**
75+
+ * Adds only allowed websites company filter count.
76+
+ *
77+
+ * @param Collection $collection
78+
+ * @throws LocalizedException
79+
+ * @throws \Zend_Db_Select_Exception
80+
+ */
81+
+ public function beforeGetSelectCountSql(Collection $collection): void
82+
+ {
83+
+ $this->filterCollection($collection);
84+
+ }
85+
+
86+
+ /**
87+
+ * Add filter to collection.
88+
+ *
89+
+ * @param Collection $collection
90+
+ * @throws LocalizedException
91+
+ * @throws \Zend_Db_Select_Exception
92+
+ */
93+
+ private function filterCollection(Collection $collection): void
94+
+ {
95+
+ $role = $this->backendAuthSession->getUser() ?
96+
+ $this->backendAuthSession->getUser()->getRole() : null;
97+
+ if ($role && !$role->getGwsIsAll() && !$collection->getFlag(self::FILTERED_FLAG_NAME)) {
98+
+ if (isset($collection->getSelect()->getPart(Select::FROM)['main_table'])
99+
+ && $this->request->getParam('id') === null) {
100+
+ $this->tableBasedFilterByCompanyAdmin($collection, $role);
101+
+ $collection->setFlag(self::FILTERED_FLAG_NAME, true);
102+
+ }
103+
+ }
104+
+ }
105+
+
106+
+ /**
107+
+ * Filter the company collection by company admins' store/website.
108+
+ *
109+
+ * @param Collection $collection
110+
+ * @param Role $role
111+
+ * @return void
112+
+ */
113+
+ private function tableBasedFilterByCompanyAdmin(Collection $collection, Role $role): void
114+
+ {
115+
+ $restrictedWebsiteIds = $role->getGwsWebsites();
116+
+
117+
+ $existsSelect = $collection->getConnection()->select()->from(
118+
+ ['admin_entity' => $collection->getTable('company_advanced_customer_entity')]
119+
+ )->joinLeft(
120+
+ ['customer_grid_flat' => $collection->getTable('customer_grid_flat')],
121+
+ 'admin_entity.customer_id = customer_grid_flat.entity_id',
122+
+ ['website_id' => 'website_id']
123+
+ )->where('customer_grid_flat.website_id IN (?)', $restrictedWebsiteIds);
124+
+
125+
+ $collection->getSelect()->exists(
126+
+ $existsSelect,
127+
+ 'admin_entity.company_id = main_table.entity_id'
128+
+ );
129+
+ }
130+
+}
131+
diff --git a/vendor/magento/module-company/etc/adminhtml/di.xml b/vendor/magento/module-company/etc/adminhtml/di.xml
132+
index 883df345fe1b..45821f657cab 100644
133+
--- a/vendor/magento/module-company/etc/adminhtml/di.xml
134+
+++ b/vendor/magento/module-company/etc/adminhtml/di.xml
135+
@@ -38,4 +38,7 @@
136+
<type name="Magento\Catalog\Model\Product\ReservedAttributeList">
137+
<plugin name="reservedAttributeListPlugin" type="Magento\Company\Plugin\Catalog\Model\Product\ReservedAttributeListPlugin"/>
138+
</type>
139+
+ <type name="Magento\Company\Model\ResourceModel\Company\Collection">
140+
+ <plugin name="admin_gws_collection_filter" type="Magento\Company\Plugin\Company\CollectionFilter"/>
141+
+ </type>
142+
</config>

0 commit comments

Comments
 (0)