File tree Expand file tree Collapse file tree 4 files changed +22
-3
lines changed
Controller/Adminhtml/Asset
js/components/grid/column/preview Expand file tree Collapse file tree 4 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 1313use Magento \Framework \Controller \ResultFactory ;
1414use Psr \Log \LoggerInterface ;
1515use Magento \AdobeStockImageAdminUi \Model \Asset \GetMediaGalleryAssetByAdobeId ;
16+ use Magento \Framework \Exception \NoSuchEntityException ;
1617
1718/**
1819 * Backend controller for retrieving asset information by adobeId
@@ -61,7 +62,6 @@ public function execute()
6162 {
6263 $ resultJson = $ this ->resultFactory ->create (ResultFactory::TYPE_JSON );
6364 try {
64-
6565 $ params = $ this ->getRequest ()->getParams ();
6666 $ adobeId = isset ($ params ['adobe_id ' ]) ? $ params ['adobe_id ' ] : null ;
6767
@@ -78,6 +78,9 @@ public function execute()
7878
7979 $ responseCode = self ::HTTP_OK ;
8080 $ responseContent = $ this ->getAssetByAdobeId ->execute ((int ) $ adobeId );
81+ } catch (NoSuchEntityException $ execption ) {
82+ $ responseCode = self ::HTTP_OK ;
83+ $ responseContent = [];
8184 } catch (\Exception $ exception ) {
8285 $ responseCode = self ::HTTP_INTERNAL_ERROR ;
8386 $ this ->logger ->critical ($ exception );
Original file line number Diff line number Diff line change 1212use Magento \MediaGalleryApi \Api \GetAssetsByIdsInterface ;
1313use Magento \MediaGalleryApi \Api \Data \AssetInterface ;
1414use Magento \Framework \Reflection \DataObjectProcessor ;
15+ use Magento \Framework \Exception \NoSuchEntityException ;
1516
1617/**
1718 * Return media gallery asset by adobe id
@@ -55,10 +56,22 @@ public function __construct(
5556 *
5657 * @param int $adobeId
5758 * @return array
59+ * @throws NoSuchEntityException
5860 */
5961 public function execute (int $ adobeId ): array
6062 {
61- $ mediaGalleryId = $ this ->getAssetByAdobeId ->execute ([$ adobeId ])[$ adobeId ]->getMediaGalleryId ();
63+ $ mediaGalleryAsset = $ this ->getAssetByAdobeId ->execute ([$ adobeId ]);
64+
65+ if (!isset ($ mediaGalleryAsset [$ adobeId ])) {
66+ throw new NoSuchEntityException (
67+ __ (
68+ 'Media Gallery asset with adobe id %id does not exist. ' ,
69+ ['id ' => $ adobeId ]
70+ )
71+ );
72+ }
73+
74+ $ mediaGalleryId = $ mediaGalleryAsset [$ adobeId ]->getMediaGalleryId ();
6275 $ asset = $ this ->getMediaGalleryAssetsById ->execute ([$ mediaGalleryId ]);
6376
6477 return $ this ->objectProcessor ->buildOutputDataArray (current ($ asset ), AssetInterface::class);
Original file line number Diff line number Diff line change 4545
4646 &-preview {
4747 position : fixed ;
48- z-index : 299 ;
48+ z-index : 289 ;
4949
5050 .container {
5151 padding-top : 0 ;
Original file line number Diff line number Diff line change @@ -170,6 +170,9 @@ define([
170170
171171 this . mediaGalleryListingFilters ( ) . clear ( ) ;
172172 this . getAssetDetails ( imageId ) . then ( function ( assetDetails ) {
173+ if ( assetDetails . length === 0 ) {
174+ return ;
175+ }
173176 this . mediaGallerySearchInput ( ) . apply ( assetDetails . title ) ;
174177 path = assetDetails . path ;
175178 path = path . substring ( 0 , path . lastIndexOf ( '/' ) ) ;
You can’t perform that action at this time.
0 commit comments