Skip to content

Commit

Permalink
Removed contruct params and added constants
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Galvao da Gama committed Jul 9, 2020
1 parent 11082e7 commit e0a777b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class GetAssetIdByCategoryStore implements GetAssetIdByContentFieldInterface
{
private const TABLE_CONTENT_ASSET = 'media_content_asset';
private const TABLE_CATALOG_CATEGORY = 'catalog_category_entity';
private const ENTITY_TYPE = 'catalog_category';

/**
* @var ResourceConnection
Expand All @@ -37,11 +38,6 @@ class GetAssetIdByCategoryStore implements GetAssetIdByContentFieldInterface
*/
private $storeGroupRepository;

/**
* @var string
*/
private $entityType;

/**
* GetAssetIdByProductStore constructor.
*
Expand All @@ -57,7 +53,6 @@ public function __construct(
$this->connection = $resource;
$this->storeRepository = $storeRepository;
$this->storeGroupRepository = $storeGroupRepository;
$this->entityType = 'catalog_category';
}

/**
Expand All @@ -75,7 +70,7 @@ public function execute(string $value): array
['asset_id']
)->where(
'entity_type = ?',
$this->entityType
self::ENTITY_TYPE
)->where(
'entity_id IN (?)',
$categoryIds
Expand Down Expand Up @@ -126,7 +121,7 @@ private function getCategoryIdsAndPath(): array
['entity_id']
)->where(
'entity_type = ?',
$this->entityType
self::ENTITY_TYPE
)->joinInner(
['category_table' => $this->connection->getTableName(self::TABLE_CATALOG_CATEGORY)],
'asset_content_table.entity_id = category_table.entity_id',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
class GetAssetIdByProductStore implements GetAssetIdByContentFieldInterface
{
private const TABLE_CONTENT_ASSET = 'media_content_asset';
private const ENTITY_TYPE = 'catalog_product';
private const FIELD_TABLE = 'catalog_product_website';
private const ID_COLUMN = 'product_id';
private const FIELD_COLUMN = 'website_id';

/**
* @var ResourceConnection
Expand All @@ -29,26 +33,6 @@ class GetAssetIdByProductStore implements GetAssetIdByContentFieldInterface
*/
private $storeRepository;

/**
* @var string
*/
private $entityType;

/**
* @var string
*/
private $fieldTable;

/**
* @var string
*/
private $fieldColumn;

/**
* @var string
*/
private $idColumn;

/**
* GetAssetIdByProductStore constructor.
*
Expand All @@ -61,10 +45,6 @@ public function __construct(
) {
$this->connection = $resource;
$this->storeRepository = $storeRepository;
$this->entityType = 'catalog_product';
$this->fieldTable = 'catalog_product_website';
$this->idColumn = 'product_id';
$this->fieldColumn = 'website_id';
}

/**
Expand All @@ -80,13 +60,13 @@ public function execute(string $value): array
['asset_id']
)->where(
'entity_type = ?',
$this->entityType
self::ENTITY_TYPE
)->joinInner(
['field_table' => $this->connection->getTableName($this->fieldTable)],
'asset_content_table.entity_id = field_table.' . $this->idColumn,
['field_table' => $this->connection->getTableName(self::FIELD_TABLE)],
'asset_content_table.entity_id = field_table.' . self::ID_COLUMN,
[]
)->where(
'field_table.' . $this->fieldColumn . ' = ?',
'field_table.' . self::FIELD_COLUMN . ' = ?',
$store->getWebsiteId()
);

Expand Down

0 comments on commit e0a777b

Please sign in to comment.