Skip to content

Commit afac929

Browse files
committed
ACPT-1052: Some Luma Storefront Scenarios Are Broken
- fix failed tests
1 parent 7a9913d commit afac929

File tree

18 files changed

+97
-74
lines changed

18 files changed

+97
-74
lines changed

app/code/Magento/Catalog/Model/CategoryRepository.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Catalog\Model;
99

10+
use Magento\Catalog\Api\CategoryRepositoryInterface;
1011
use Magento\Catalog\Model\CategoryRepository\PopulateWithValues;
1112
use Magento\Catalog\Model\ResourceModel\Category as CategoryResource;
1213
use Magento\Framework\Api\ExtensibleDataObjectConverter;
@@ -24,7 +25,8 @@
2425
*
2526
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2627
*/
27-
class CategoryRepository implements \Magento\Catalog\Api\CategoryRepositoryInterface,
28+
class CategoryRepository implements
29+
CategoryRepositoryInterface,
2830
ResetAfterRequestInterface
2931
{
3032
/**
@@ -232,7 +234,7 @@ protected function validateCategory(Category $category)
232234
*
233235
* @return ExtensibleDataObjectConverter
234236
*
235-
* @deprecated 101.0.0
237+
* @deprecated 101.0.0 @see we don't recommend this approach anymore
236238
*/
237239
private function getExtensibleDataObjectConverter()
238240
{

app/code/Magento/Catalog/Model/Product.php

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,22 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements
5757
* Entity code.
5858
* Can be used as part of method name for entity processing
5959
*/
60-
const ENTITY = 'catalog_product';
60+
public const ENTITY = 'catalog_product';
6161

6262
/**
6363
* Product cache tag
6464
*/
65-
const CACHE_TAG = 'cat_p';
65+
public const CACHE_TAG = 'cat_p';
6666

6767
/**
6868
* Category product relation cache tag
6969
*/
70-
const CACHE_PRODUCT_CATEGORY_TAG = 'cat_c_p';
70+
public const CACHE_PRODUCT_CATEGORY_TAG = 'cat_c_p';
7171

7272
/**
7373
* Product Store Id
7474
*/
75-
const STORE_ID = 'store_id';
75+
public const STORE_ID = 'store_id';
7676

7777
/**
7878
* @var string|bool
@@ -172,8 +172,6 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements
172172
protected $_calculatePrice = true;
173173

174174
/**
175-
* Catalog product
176-
*
177175
* @var \Magento\Catalog\Helper\Product
178176
*/
179177
protected $_catalogProduct = null;
@@ -189,43 +187,31 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements
189187
protected $_collectionFactory;
190188

191189
/**
192-
* Catalog product type
193-
*
194190
* @var Product\Type
195191
*/
196192
protected $_catalogProductType;
197193

198194
/**
199-
* Catalog product media config
200-
*
201195
* @var Product\Media\Config
202196
*/
203197
protected $_catalogProductMediaConfig;
204198

205199
/**
206-
* Catalog product status
207-
*
208200
* @var Status
209201
*/
210202
protected $_catalogProductStatus;
211203

212204
/**
213-
* Catalog product visibility
214-
*
215205
* @var Product\Visibility
216206
*/
217207
protected $_catalogProductVisibility;
218208

219209
/**
220-
* Stock item factory
221-
*
222210
* @var \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory
223211
*/
224212
protected $_stockItemFactory;
225213

226214
/**
227-
* Item option factory
228-
*
229215
* @var \Magento\Catalog\Model\Product\Configuration\Item\OptionFactory
230216
*/
231217
protected $_itemOptionFactory;
@@ -281,27 +267,27 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements
281267

282268
/**
283269
* @var \Magento\Catalog\Api\ProductAttributeRepositoryInterface
284-
* @deprecated 102.0.6 Not used anymore due to performance issue (loaded all product attributes)
270+
* @deprecated 102.0.6 @see Not used anymore due to performance issue (loaded all product attributes)
285271
*/
286272
protected $metadataService;
287273

288274
/**
289-
* @param \Magento\Catalog\Model\ProductLink\CollectionProvider
275+
* @var \Magento\Catalog\Model\ProductLink\CollectionProvider
290276
*/
291277
protected $entityCollectionProvider;
292278

293279
/**
294-
* @param \Magento\Catalog\Model\Product\LinkTypeProvider
280+
* @var \Magento\Catalog\Model\Product\LinkTypeProvider
295281
*/
296282
protected $linkProvider;
297283

298284
/**
299-
* @param \Magento\Catalog\Api\Data\ProductLinkInterfaceFactory
285+
* @var \Magento\Catalog\Api\Data\ProductLinkInterfaceFactory
300286
*/
301287
protected $productLinkFactory;
302288

303289
/**
304-
* @param \Magento\Catalog\Api\Data\ProductLinkExtensionFactory
290+
* @var \Magento\Catalog\Api\Data\ProductLinkExtensionFactory
305291
*/
306292
protected $productLinkExtensionFactory;
307293

@@ -496,7 +482,7 @@ protected function _construct()
496482
*
497483
* @throws \Magento\Framework\Exception\LocalizedException
498484
* @return \Magento\Catalog\Model\ResourceModel\Product
499-
* @deprecated 102.0.6 because resource models should be used directly
485+
* @deprecated 102.0.6 @see \Magento\Catalog\Model\ResourceModel\Product
500486
* @since 102.0.6
501487
*/
502488
protected function _getResource()
@@ -644,7 +630,7 @@ public function getUpdatedAt()
644630
*
645631
* @param bool $calculate
646632
* @return void
647-
* @deprecated 102.0.4
633+
* @deprecated 102.0.4 @see we don't recommend this approach anymore
648634
*/
649635
public function setPriceCalculation($calculate = true)
650636
{

app/code/Magento/Catalog/Model/Product/Image/Cache.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ protected function getData()
6767
]);
6868
$images = $config->getMediaEntities('Magento_Catalog', ImageHelper::MEDIA_TYPE_CONFIG_NODE);
6969
foreach ($images as $imageId => $imageData) {
70+
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
7071
$this->data[$theme->getCode() . $imageId] = array_merge(['id' => $imageId], $imageData);
7172
}
7273
}

app/code/Magento/Catalog/Model/Product/Media/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,6 @@ private function getAttributeHelper()
206206
*/
207207
public function _resetState(): void
208208
{
209-
$this->mediaAttributeCodes = [];
209+
$this->mediaAttributeCodes = [];
210210
}
211211
}

app/code/Magento/Catalog/Model/ProductRepository.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,14 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa
130130
protected $fileSystem;
131131

132132
/**
133-
* @deprecated 103.0.2
133+
* @deprecated 103.0.2 @see nothing
134134
*
135135
* @var ImageContentInterfaceFactory
136136
*/
137137
protected $contentFactory;
138138

139139
/**
140-
* @deprecated 103.0.2
140+
* @deprecated 103.0.2 @see nothing
141141
*
142142
* @var ImageProcessorInterface
143143
*/
@@ -149,7 +149,7 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa
149149
protected $extensionAttributesJoinProcessor;
150150

151151
/**
152-
* @deprecated 103.0.2
152+
* @deprecated 103.0.2 @see nothing
153153
*
154154
* @var \Magento\Catalog\Model\Product\Gallery\Processor
155155
*/
@@ -736,7 +736,7 @@ private function addExtensionAttributes(Collection $collection) : Collection
736736
/**
737737
* Helper function that adds a FilterGroup to the collection.
738738
*
739-
* @deprecated 102.0.0
739+
* @deprecated 102.0.0 @see nothing
740740
* @param \Magento\Framework\Api\Search\FilterGroup $filterGroup
741741
* @param Collection $collection
742742
* @return void
@@ -795,7 +795,7 @@ private function getMediaGalleryProcessor()
795795
/**
796796
* Retrieve collection processor
797797
*
798-
* @deprecated 102.0.0
798+
* @deprecated 102.0.0 @see nothing
799799
* @return CollectionProcessorInterface
800800
*/
801801
private function getCollectionProcessor()

app/code/Magento/Catalog/Model/ResourceModel/Attribute/WebsiteAttributesSynchronizer.php

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,22 @@
1616
use Magento\Framework\FlagManager;
1717
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1818

19-
/**
20-
* Class WebsiteAttributesSynchronizer
21-
* @package Magento\Catalog\Cron
22-
*/
2319
class WebsiteAttributesSynchronizer implements ResetAfterRequestInterface
2420
{
25-
const FLAG_SYNCHRONIZED = 0;
26-
const FLAG_SYNCHRONIZATION_IN_PROGRESS = 1;
27-
const FLAG_REQUIRES_SYNCHRONIZATION = 2;
28-
const FLAG_NAME = 'catalog_website_attribute_is_sync_required';
21+
public const FLAG_SYNCHRONIZED = 0;
22+
public const FLAG_SYNCHRONIZATION_IN_PROGRESS = 1;
23+
public const FLAG_REQUIRES_SYNCHRONIZATION = 2;
24+
public const FLAG_NAME = 'catalog_website_attribute_is_sync_required';
2925

30-
const ATTRIBUTE_WEBSITE = 2;
31-
const GLOBAL_STORE_VIEW_ID = 0;
26+
public const ATTRIBUTE_WEBSITE = 2;
27+
public const GLOBAL_STORE_VIEW_ID = 0;
3228

33-
const MASK_ATTRIBUTE_VALUE = '%d_%d_%d';
29+
public const MASK_ATTRIBUTE_VALUE = '%d_%d_%d';
3430

3531
/**
3632
* Map table names to metadata classes where link field might be found
33+
*
34+
* @var string[]
3735
*/
3836
private $tableMetaDataClass = [
3937
'catalog_category_entity_datetime' => CategoryInterface::class,
@@ -102,7 +100,7 @@ class WebsiteAttributesSynchronizer implements ResetAfterRequestInterface
102100
* WebsiteAttributesSynchronizer constructor.
103101
* @param ResourceConnection $resourceConnection
104102
* @param FlagManager $flagManager
105-
* @param Generator $batchQueryGenerator,
103+
* @param Generator $batchQueryGenerator
106104
* @param MetadataPool $metadataPool
107105
*/
108106
public function __construct(
@@ -120,6 +118,7 @@ public function __construct(
120118

121119
/**
122120
* Synchronizes attribute values between different store views on website level
121+
*
123122
* @return void
124123
* @throws \Exception
125124
*/
@@ -142,6 +141,8 @@ public function synchronize()
142141
}
143142

144143
/**
144+
* Check if synchronization required
145+
*
145146
* @return bool
146147
*/
147148
public function isSynchronizationRequired()
@@ -151,6 +152,7 @@ public function isSynchronizationRequired()
151152

152153
/**
153154
* Puts a flag that synchronization is required
155+
*
154156
* @return void
155157
*/
156158
public function scheduleSynchronization()
@@ -160,6 +162,7 @@ public function scheduleSynchronization()
160162

161163
/**
162164
* Marks flag as in progress in case if several crons enabled, so sync. won't be duplicated
165+
*
163166
* @return void
164167
*/
165168
private function markSynchronizationInProgress()
@@ -169,6 +172,7 @@ private function markSynchronizationInProgress()
169172

170173
/**
171174
* Turn off synchronization flag
175+
*
172176
* @return void
173177
*/
174178
private function markSynchronized()
@@ -177,6 +181,8 @@ private function markSynchronized()
177181
}
178182

179183
/**
184+
* Perform table synchronization
185+
*
180186
* @param string $tableName
181187
* @return void
182188
*/
@@ -189,6 +195,7 @@ private function synchronizeTable($tableName)
189195

190196
/**
191197
* Aligns website attribute values
198+
*
192199
* @param array $attributeValueItems
193200
* @param string $tableName
194201
* @return void
@@ -258,6 +265,8 @@ private function fetchAttributeValues($tableName)
258265
}
259266

260267
/**
268+
* Retrieve grouped store views
269+
*
261270
* @return array
262271
*/
263272
private function getGroupedStoreViews()
@@ -287,6 +296,8 @@ private function getGroupedStoreViews()
287296
}
288297

289298
/**
299+
* Check if attribute value processed
300+
*
290301
* @param array $attributeValue
291302
* @param string $tableName
292303
* @return bool
@@ -305,6 +316,7 @@ private function isAttributeValueProcessed(array $attributeValue, $tableName)
305316

306317
/**
307318
* Resets processed attribute values
319+
*
308320
* @return void
309321
*/
310322
private function resetProcessedAttributeValues()
@@ -313,6 +325,8 @@ private function resetProcessedAttributeValues()
313325
}
314326

315327
/**
328+
* Mark processed attribute value
329+
*
316330
* @param array $attributeValue
317331
* @param string $tableName
318332
* @return void
@@ -327,6 +341,8 @@ private function markAttributeValueProcessed(array $attributeValue, $tableName)
327341
}
328342

329343
/**
344+
* Retrieve attribute value key
345+
*
330346
* @param int $entityId
331347
* @param int $attributeId
332348
* @param int $websiteId
@@ -343,6 +359,8 @@ private function getAttributeValueKey($entityId, $attributeId, $websiteId)
343359
}
344360

345361
/**
362+
* generate insertions for attribute value
363+
*
346364
* @param array $attributeValue
347365
* @param string $tableName
348366
* @return array|null
@@ -370,6 +388,8 @@ private function generateAttributeValueInsertions(array $attributeValue, $tableN
370388
}
371389

372390
/**
391+
* Insert attribute values into table
392+
*
373393
* @param array $insertions
374394
* @param string $tableName
375395
* @return void
@@ -400,6 +420,7 @@ private function getPlaceholderValues(array $insertions)
400420
{
401421
$placeholderValues = [];
402422
foreach ($insertions as $insertion) {
423+
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
403424
$placeholderValues = array_merge(
404425
$placeholderValues,
405426
$insertion
@@ -427,6 +448,8 @@ private function prepareInsertValuesStatement(array $insertions)
427448
}
428449

429450
/**
451+
* Retrieve table link field
452+
*
430453
* @param string $tableName
431454
* @return string
432455
* @throws LocalizedException

0 commit comments

Comments
 (0)