55 */
66declare (strict_types=1 );
77
8- namespace Magento \MediaContentCatalog \Model ;
8+ namespace Magento \MediaContentCatalog \Model \ ResourceModel ;
99
1010use Magento \Eav \Model \Config ;
1111use Magento \Framework \App \ResourceConnection ;
12- use Magento \MediaContentApi \Model \GetAssetIdByContentFieldInterface ;
12+ use Magento \MediaContentApi \Model \GetAssetIdsByContentFieldInterface ;
1313
1414/**
1515 * Class responsible to return Asset id by eav content field
1616 */
17- class GetAssetIdByEavContentField implements GetAssetIdByContentFieldInterface
17+ class GetAssetIdsByEavContentField implements GetAssetIdsByContentFieldInterface
1818{
1919 private const TABLE_CONTENT_ASSET = 'media_content_asset ' ;
2020
@@ -44,7 +44,7 @@ class GetAssetIdByEavContentField implements GetAssetIdByContentFieldInterface
4444 private $ valueMap ;
4545
4646 /**
47- * GetAssetIdByEavContentStatus constructor.
47+ * GetAssetIdsByEavContentField constructor.
4848 *
4949 * @param ResourceConnection $resource
5050 * @param Config $config
@@ -71,7 +71,7 @@ public function __construct(
7171 */
7272 public function execute (string $ value ): array
7373 {
74- $ statusAttribute = $ this ->config ->getAttribute ($ this ->entityType , $ this ->attributeCode );
74+ $ attribute = $ this ->config ->getAttribute ($ this ->entityType , $ this ->attributeCode );
7575
7676 $ sql = $ this ->connection ->getConnection ()->select ()->from (
7777 ['asset_content_table ' => $ this ->connection ->getTableName (self ::TABLE_CONTENT_ASSET )],
@@ -80,10 +80,10 @@ public function execute(string $value): array
8080 'entity_type = ? ' ,
8181 $ this ->entityType
8282 )->joinInner (
83- ['entity_eav_type ' => $ statusAttribute ->getBackendTable ()],
84- 'asset_content_table.entity_id = entity_eav_type. ' . $ statusAttribute ->getEntityIdField () .
83+ ['entity_eav_type ' => $ attribute ->getBackendTable ()],
84+ 'asset_content_table.entity_id = entity_eav_type. ' . $ attribute ->getEntityIdField () .
8585 ' AND entity_eav_type.attribute_id = ' .
86- $ statusAttribute ->getAttributeId (),
86+ $ attribute ->getAttributeId (),
8787 []
8888 )->where (
8989 'entity_eav_type.value = ? ' ,
@@ -101,9 +101,6 @@ public function execute(string $value): array
101101 */
102102 private function getValueFromMap (string $ value ): string
103103 {
104- if (count ($ this ->valueMap ) > 0 && array_key_exists ($ value , $ this ->valueMap )) {
105- return $ this ->valueMap [$ value ];
106- }
107- return $ value ;
104+ return $ this ->valueMap [$ value ] ?? $ value ;
108105 }
109106}
0 commit comments