Skip to content

Commit 8a184d7

Browse files
authored
Merge pull request #147 from magento-commerce/1.1.42-release
1.1.42 Release
2 parents ab775cf + 3c82426 commit 8a184d7

26 files changed

+2735
-13
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.41",
5+
"version": "1.1.42",
66
"license": "proprietary",
77
"repositories": {
88
"repo": {

patches-info.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
diff --git a/vendor/magento/module-shared-catalog/Model/ProductManagement.php b/vendor/magento/module-shared-catalog/Model/ProductManagement.php
2+
index 24bf11605b..e0a6caad01 100644
3+
--- a/vendor/magento/module-shared-catalog/Model/ProductManagement.php
4+
+++ b/vendor/magento/module-shared-catalog/Model/ProductManagement.php
5+
@@ -6,8 +6,11 @@
6+
namespace Magento\SharedCatalog\Model;
7+
8+
use Magento\Catalog\Api\ProductRepositoryInterface;
9+
+use Magento\Catalog\Model\ResourceModel\Product as ProductResourceModel;
10+
+use Magento\Catalog\Model\ResourceModel\Product\CategoryLink;
11+
use Magento\Customer\Api\Data\GroupInterface;
12+
use Magento\Framework\Api\SearchCriteriaBuilder;
13+
+use Magento\Framework\App\ObjectManager;
14+
use Magento\SharedCatalog\Api\CategoryManagementInterface;
15+
use Magento\SharedCatalog\Api\Data\ProductItemInterface;
16+
use Magento\SharedCatalog\Api\Data\SharedCatalogInterface;
17+
@@ -17,6 +20,8 @@ use Magento\SharedCatalog\Api\ProductManagementInterface;
18+
19+
/**
20+
* Shared catalog products actions.
21+
+ *
22+
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
23+
*/
24+
class ProductManagement implements ProductManagementInterface
25+
{
26+
@@ -62,6 +67,16 @@ class ProductManagement implements ProductManagementInterface
27+
*/
28+
private $batchSize;
29+
30+
+ /**
31+
+ * @var ProductResourceModel
32+
+ */
33+
+ private $productResourceModel;
34+
+
35+
+ /**
36+
+ * @var CategoryLink
37+
+ */
38+
+ private $productCategoryLink;
39+
+
40+
/**
41+
* ProductSharedCatalogsManagement constructor.
42+
*
43+
@@ -73,6 +88,9 @@ class ProductManagement implements ProductManagementInterface
44+
* @param ProductRepositoryInterface $productRepository
45+
* @param CatalogPermissionManagement $catalogPermissionManagement
46+
* @param int $batchSize defines how many items can be processed by one iteration
47+
+ * @param ProductResourceModel|null $productResourceModel
48+
+ * @param CategoryLink|null $productCategoryLink
49+
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
50+
*/
51+
public function __construct(
52+
ProductItemManagementInterface $productItemManagement,
53+
@@ -82,7 +100,9 @@ class ProductManagement implements ProductManagementInterface
54+
CategoryManagementInterface $sharedCatalogCategoryManagement,
55+
ProductRepositoryInterface $productRepository,
56+
CatalogPermissionManagement $catalogPermissionManagement,
57+
- int $batchSize = 5000
58+
+ int $batchSize = 5000,
59+
+ ProductResourceModel $productResourceModel = null,
60+
+ CategoryLink $productCategoryLink = null
61+
) {
62+
$this->sharedCatalogProductItemManagement = $productItemManagement;
63+
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
64+
@@ -92,6 +112,10 @@ class ProductManagement implements ProductManagementInterface
65+
$this->productRepository = $productRepository;
66+
$this->catalogPermissionManagement = $catalogPermissionManagement;
67+
$this->batchSize = $batchSize;
68+
+ $this->productResourceModel = $productResourceModel
69+
+ ?? ObjectManager::getInstance()->get(ProductResourceModel::class);
70+
+ $this->productCategoryLink = $productCategoryLink
71+
+ ?? ObjectManager::getInstance()->get(CategoryLink::class);
72+
}
73+
74+
/**
75+
@@ -134,26 +158,36 @@ class ProductManagement implements ProductManagementInterface
76+
$customerGroupIds = $this->getAssociatedCustomerGroupIds($sharedCatalog);
77+
78+
$skus = [];
79+
+ $ids = [];
80+
foreach ($products as $product) {
81+
- $skus[] = $product->getSku();
82+
+ if ($product->getSku()) {
83+
+ $skus[] = $product->getSku();
84+
+ } elseif ($product->getId()) {
85+
+ $ids[] = $product->getId();
86+
+ }
87+
}
88+
+
89+
+ if (!empty($ids)) {
90+
+ $skus = array_merge($skus, array_column($this->productResourceModel->getProductsSku($ids), 'sku'));
91+
+ }
92+
+
93+
$skus = array_unique($skus);
94+
95+
+ $ids = [];
96+
+ if (!empty($skus)) {
97+
+ $ids = array_values($this->productResourceModel->getProductsIdsBySkus($skus));
98+
+ }
99+
+
100+
$categoryIds = $this->sharedCatalogCategoryManagement->getCategories($sharedCatalog->getId());
101+
- $productsCategoryIds = $this->getProductsCategoryIds($skus);
102+
+ $productsCategoryIds = $this->productCategoryLink->getCategoryIdsByProductIds($ids);
103+
$assignCategoriesIds = array_diff($productsCategoryIds, $categoryIds);
104+
- $this->catalogPermissionManagement->setAllowPermissions($assignCategoriesIds, $customerGroupIds);
105+
106+
foreach ($customerGroupIds as $customerGroupId) {
107+
$this->sharedCatalogProductItemManagement->addItems($customerGroupId, $skus);
108+
}
109+
- $ids = [];
110+
- foreach ($products as $product) {
111+
- if ($product->getId()) {
112+
- $ids[] = $product->getId();
113+
- }
114+
- }
115+
+
116+
$this->sharedCatalogInvalidation->reindexCatalogProductPermissions($ids);
117+
+ $this->catalogPermissionManagement->setAllowPermissions($assignCategoriesIds, $customerGroupIds);
118+
119+
return true;
120+
}
121+
@@ -247,22 +281,4 @@ class ProductManagement implements ProductManagementInterface
122+
123+
return $customerGroupIds;
124+
}
125+
-
126+
- /**
127+
- * Get categories id for products
128+
- *
129+
- * @param string[] $skus
130+
- * @return int[]
131+
- */
132+
- private function getProductsCategoryIds(array $skus): array
133+
- {
134+
- $productsCategoryIds = [];
135+
- foreach ($skus as $sku) {
136+
- $product = $this->productRepository->get($sku);
137+
- $productsCategoryIds[] = (array) $product->getCategoryIds();
138+
- }
139+
- $productsCategoryIds = array_unique(array_merge([], ...$productsCategoryIds));
140+
-
141+
- return $productsCategoryIds;
142+
- }
143+
}
144+
diff --git a/vendor/magento/module-shared-catalog/etc/mview.xml b/vendor/magento/module-shared-catalog/etc/mview.xml
145+
index 09afb1e7d8..e1a8e8477b 100644
146+
--- a/vendor/magento/module-shared-catalog/etc/mview.xml
147+
+++ b/vendor/magento/module-shared-catalog/etc/mview.xml
148+
@@ -11,4 +11,14 @@
149+
<table name="sharedcatalog_category_permissions" entity_column="category_id"/>
150+
</subscriptions>
151+
</view>
152+
+ <view id="catalogpermissions_product" class="Magento\CatalogPermissions\Model\Indexer\Product" group="indexer">
153+
+ <subscriptions>
154+
+ <table name="shared_catalog_product_item" subscription_model="Magento\Catalog\Model\Mview\View\Sku\Subscription" entity_column="sku"/>
155+
+ </subscriptions>
156+
+ </view>
157+
+ <view id="catalogsearch_fulltext" class="\Magento\CatalogSearch\Model\Indexer\Mview\Action" group="indexer">
158+
+ <subscriptions>
159+
+ <table name="shared_catalog_product_item" subscription_model="Magento\Catalog\Model\Mview\View\Sku\Subscription" entity_column="sku"/>
160+
+ </subscriptions>
161+
+ </view>
162+
</config>
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
diff --git a/vendor/magento/module-catalog-permissions/Model/Indexer/Product/Action/GetProductsCategories.php b/vendor/magento/module-catalog-permissions/Model/Indexer/Product/Action/GetProductsCategories.php
2+
new file mode 100644
3+
index 00000000000..cf6bce34345
4+
--- /dev/null
5+
+++ b/vendor/magento/module-catalog-permissions/Model/Indexer/Product/Action/GetProductsCategories.php
6+
@@ -0,0 +1,84 @@
7+
+<?php
8+
+/************************************************************************
9+
+ *
10+
+ * ADOBE CONFIDENTIAL
11+
+ * ___________________
12+
+ *
13+
+ * Copyright 2023 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\CatalogPermissions\Model\Indexer\Product\Action;
29+
+
30+
+use Magento\Catalog\Model\Indexer\Category\Product\TableMaintainer as CategoryProductTableMaintainer;
31+
+use Magento\Framework\App\ResourceConnection;
32+
+use Magento\Store\Model\StoreManagerInterface;
33+
+
34+
+class GetProductsCategories
35+
+{
36+
+ /**
37+
+ * @var ResourceConnection
38+
+ */
39+
+ private $resource;
40+
+
41+
+ /**
42+
+ * @var CategoryProductTableMaintainer
43+
+ */
44+
+ private $categoryProductTableMaintainer;
45+
+
46+
+ /**
47+
+ * @var StoreManagerInterface
48+
+ */
49+
+ private $storeManager;
50+
+
51+
+ /**
52+
+ * @param ResourceConnection $resource
53+
+ * @param CategoryProductTableMaintainer $categoryProductTableMaintainer
54+
+ * @param StoreManagerInterface $storeManager
55+
+ */
56+
+ public function __construct(
57+
+ ResourceConnection $resource,
58+
+ CategoryProductTableMaintainer $categoryProductTableMaintainer,
59+
+ StoreManagerInterface $storeManager
60+
+ ) {
61+
+ $this->resource = $resource;
62+
+ $this->categoryProductTableMaintainer = $categoryProductTableMaintainer;
63+
+ $this->storeManager = $storeManager;
64+
+ }
65+
+
66+
+ /**
67+
+ * Returns list of categories ids for provided products
68+
+ *
69+
+ * @param int[] $productList
70+
+ * @return array
71+
+ */
72+
+ public function execute(
73+
+ array $productList
74+
+ ): array {
75+
+ $connection = $this->resource->getConnection();
76+
+ $categories = [];
77+
+ foreach ($this->storeManager->getStores() as $store) {
78+
+ $select = $connection->select()->from(
79+
+ ['category_product_index' => $this->categoryProductTableMaintainer->getMainTable((int)$store->getId())],
80+
+ ['category_product_index.category_id']
81+
+ );
82+
+ $select->where('category_product_index.product_id IN (?)', $productList, \Zend_Db::INT_TYPE);
83+
+ $select->distinct(true);
84+
+
85+
+ $categories += array_fill_keys($connection->fetchCol($select), true);
86+
+ }
87+
+
88+
+ return array_keys($categories);
89+
+ }
90+
+}
91+
diff --git a/vendor/magento/module-catalog-permissions/Model/Indexer/Product/Action/Rows.php b/vendor/magento/module-catalog-permissions/Model/Indexer/Product/Action/Rows.php
92+
index a08a297570b..7cf01aad9eb 100644
93+
--- a/vendor/magento/module-catalog-permissions/Model/Indexer/Product/Action/Rows.php
94+
+++ b/vendor/magento/module-catalog-permissions/Model/Indexer/Product/Action/Rows.php
95+
@@ -5,7 +5,24 @@
96+
*/
97+
namespace Magento\CatalogPermissions\Model\Indexer\Product\Action;
98+
99+
+use Magento\Catalog\Model\Category;
100+
+use Magento\Catalog\Model\Config as CatalogConfig;
101+
+use Magento\Catalog\Model\Product;
102+
+use Magento\CatalogPermissions\App\ConfigInterface;
103+
use Magento\CatalogPermissions\Model\Indexer\AbstractAction;
104+
+use Magento\CatalogPermissions\Model\Indexer\Category\ModeSwitcher;
105+
+use Magento\CatalogPermissions\Model\Indexer\TableMaintainer;
106+
+use Magento\Customer\Model\ResourceModel\Group\CollectionFactory as GroupCollectionFactory;
107+
+use Magento\Framework\App\CacheInterface;
108+
+use Magento\Framework\App\Config\ScopeConfigInterface;
109+
+use Magento\Framework\App\ObjectManager;
110+
+use Magento\Framework\App\ResourceConnection;
111+
+use Magento\Framework\DB\Query\Generator;
112+
+use Magento\Framework\EntityManager\MetadataPool;
113+
+use Magento\Framework\Indexer\CacheContext;
114+
+use Magento\Store\Model\ResourceModel\Website\CollectionFactory as WebsiteCollectionFactory;
115+
+use Magento\CatalogPermissions\Model\Indexer\Product\IndexFiller as ProductIndexFiller;
116+
+use Magento\Store\Model\StoreManagerInterface;
117+
118+
/**
119+
* @api
120+
@@ -20,6 +37,76 @@ class Rows extends AbstractAction
121+
*/
122+
protected $entityIds;
123+
124+
+ /**
125+
+ * @var ScopeConfigInterface
126+
+ */
127+
+ private $scopeConfig;
128+
+
129+
+ /**
130+
+ * @var CacheContext
131+
+ */
132+
+ private $cacheContext;
133+
+
134+
+ /**
135+
+ * @var GetProductsCategories
136+
+ */
137+
+ private $getProductsCategories;
138+
+
139+
+ /**
140+
+ * @param ResourceConnection $resource
141+
+ * @param WebsiteCollectionFactory $websiteCollectionFactory
142+
+ * @param GroupCollectionFactory $groupCollectionFactory
143+
+ * @param ConfigInterface $config
144+
+ * @param StoreManagerInterface $storeManager
145+
+ * @param CatalogConfig $catalogConfig
146+
+ * @param CacheInterface $coreCache
147+
+ * @param MetadataPool $metadataPool
148+
+ * @param Generator|null $batchQueryGenerator
149+
+ * @param ProductSelectDataProvider|null $productSelectDataProvider
150+
+ * @param ProductIndexFiller|null $productIndexFiller
151+
+ * @param TableMaintainer|null $tableMaintainer
152+
+ * @param ScopeConfigInterface|null $scopeConfig
153+
+ * @param CacheContext|null $cacheContext
154+
+ * @param GetProductsCategories|null $getProductsCategories
155+
+ * @throws \Exception
156+
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
157+
+ */
158+
+ public function __construct(
159+
+ ResourceConnection $resource,
160+
+ WebsiteCollectionFactory $websiteCollectionFactory,
161+
+ GroupCollectionFactory $groupCollectionFactory,
162+
+ ConfigInterface $config,
163+
+ StoreManagerInterface $storeManager,
164+
+ CatalogConfig $catalogConfig,
165+
+ CacheInterface $coreCache,
166+
+ \Magento\Framework\EntityManager\MetadataPool $metadataPool,
167+
+ Generator $batchQueryGenerator = null,
168+
+ ProductSelectDataProvider $productSelectDataProvider = null,
169+
+ ProductIndexFiller $productIndexFiller = null,
170+
+ ?CacheContext $cacheContext = null,
171+
+ ?GetProductsCategories $getProductsCategories = null
172+
+ ) {
173+
+ parent::__construct(
174+
+ $resource,
175+
+ $websiteCollectionFactory,
176+
+ $groupCollectionFactory,
177+
+ $config,
178+
+ $storeManager,
179+
+ $catalogConfig,
180+
+ $coreCache,
181+
+ $metadataPool,
182+
+ $batchQueryGenerator,
183+
+ $productSelectDataProvider,
184+
+ $productIndexFiller
185+
+ );
186+
+ $this->scopeConfig = $scopeConfig
187+
+ ??ObjectManager::getInstance()->get(ScopeConfigInterface::class);
188+
+ $this->cacheContext = $cacheContext
189+
+ ?? ObjectManager::getInstance()->get(CacheContext::class);
190+
+ $this->getProductsCategories = $getProductsCategories
191+
+ ?? ObjectManager::getInstance()->get(GetProductsCategories::class);
192+
+ }
193+
+
194+
/**
195+
* Refresh entities index
196+
*
197+
@@ -36,6 +123,14 @@ class Rows extends AbstractAction
198+
$this->removeObsoleteIndexData();
199+
200+
$this->reindex();
201+
+ $this->cacheContext->registerEntities(
202+
+ Product::CACHE_TAG,
203+
+ $entityIds
204+
+ );
205+
+ $this->cacheContext->registerEntities(
206+
+ Category::CACHE_TAG,
207+
+ $this->getProductsCategories->execute($entityIds)
208+
+ );
209+
}
210+
}
211+

0 commit comments

Comments
 (0)