Skip to content

Commit e0a777b

Browse files
author
Gabriel Galvao da Gama
committed
Removed contruct params and added constants
1 parent 11082e7 commit e0a777b

File tree

2 files changed

+11
-36
lines changed

2 files changed

+11
-36
lines changed

app/code/Magento/MediaContentCatalog/Model/GetAssetIdByCategoryStore.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class GetAssetIdByCategoryStore implements GetAssetIdByContentFieldInterface
2121
{
2222
private const TABLE_CONTENT_ASSET = 'media_content_asset';
2323
private const TABLE_CATALOG_CATEGORY = 'catalog_category_entity';
24+
private const ENTITY_TYPE = 'catalog_category';
2425

2526
/**
2627
* @var ResourceConnection
@@ -37,11 +38,6 @@ class GetAssetIdByCategoryStore implements GetAssetIdByContentFieldInterface
3738
*/
3839
private $storeGroupRepository;
3940

40-
/**
41-
* @var string
42-
*/
43-
private $entityType;
44-
4541
/**
4642
* GetAssetIdByProductStore constructor.
4743
*
@@ -57,7 +53,6 @@ public function __construct(
5753
$this->connection = $resource;
5854
$this->storeRepository = $storeRepository;
5955
$this->storeGroupRepository = $storeGroupRepository;
60-
$this->entityType = 'catalog_category';
6156
}
6257

6358
/**
@@ -75,7 +70,7 @@ public function execute(string $value): array
7570
['asset_id']
7671
)->where(
7772
'entity_type = ?',
78-
$this->entityType
73+
self::ENTITY_TYPE
7974
)->where(
8075
'entity_id IN (?)',
8176
$categoryIds
@@ -126,7 +121,7 @@ private function getCategoryIdsAndPath(): array
126121
['entity_id']
127122
)->where(
128123
'entity_type = ?',
129-
$this->entityType
124+
self::ENTITY_TYPE
130125
)->joinInner(
131126
['category_table' => $this->connection->getTableName(self::TABLE_CATALOG_CATEGORY)],
132127
'asset_content_table.entity_id = category_table.entity_id',

app/code/Magento/MediaContentCatalog/Model/GetAssetIdByProductStore.php

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
class GetAssetIdByProductStore implements GetAssetIdByContentFieldInterface
1919
{
2020
private const TABLE_CONTENT_ASSET = 'media_content_asset';
21+
private const ENTITY_TYPE = 'catalog_product';
22+
private const FIELD_TABLE = 'catalog_product_website';
23+
private const ID_COLUMN = 'product_id';
24+
private const FIELD_COLUMN = 'website_id';
2125

2226
/**
2327
* @var ResourceConnection
@@ -29,26 +33,6 @@ class GetAssetIdByProductStore implements GetAssetIdByContentFieldInterface
2933
*/
3034
private $storeRepository;
3135

32-
/**
33-
* @var string
34-
*/
35-
private $entityType;
36-
37-
/**
38-
* @var string
39-
*/
40-
private $fieldTable;
41-
42-
/**
43-
* @var string
44-
*/
45-
private $fieldColumn;
46-
47-
/**
48-
* @var string
49-
*/
50-
private $idColumn;
51-
5236
/**
5337
* GetAssetIdByProductStore constructor.
5438
*
@@ -61,10 +45,6 @@ public function __construct(
6145
) {
6246
$this->connection = $resource;
6347
$this->storeRepository = $storeRepository;
64-
$this->entityType = 'catalog_product';
65-
$this->fieldTable = 'catalog_product_website';
66-
$this->idColumn = 'product_id';
67-
$this->fieldColumn = 'website_id';
6848
}
6949

7050
/**
@@ -80,13 +60,13 @@ public function execute(string $value): array
8060
['asset_id']
8161
)->where(
8262
'entity_type = ?',
83-
$this->entityType
63+
self::ENTITY_TYPE
8464
)->joinInner(
85-
['field_table' => $this->connection->getTableName($this->fieldTable)],
86-
'asset_content_table.entity_id = field_table.' . $this->idColumn,
65+
['field_table' => $this->connection->getTableName(self::FIELD_TABLE)],
66+
'asset_content_table.entity_id = field_table.' . self::ID_COLUMN,
8767
[]
8868
)->where(
89-
'field_table.' . $this->fieldColumn . ' = ?',
69+
'field_table.' . self::FIELD_COLUMN . ' = ?',
9070
$store->getWebsiteId()
9171
);
9272

0 commit comments

Comments
 (0)