@@ -88,32 +88,33 @@ public function __construct(
8888 public function removeDeletedImagesFromCache (array $ files )
8989 {
9090 if (count ($ files ) > 0 ) {
91- $ imageArguments = $ this ->presentationConfig
91+ $ images = $ this ->presentationConfig
9292 ->getViewConfig (['area ' => \Magento \Framework \App \Area::AREA_FRONTEND ])
93- ->getMediaAttributes (
93+ ->getMediaEntities (
9494 'Magento_Catalog ' ,
95- Image::MEDIA_TYPE_CONFIG_NODE ,
96- 'product_page_image_small '
95+ Image::MEDIA_TYPE_CONFIG_NODE
9796 );
9897
99- $ imageMiscParams = $ this ->imageParamsBuilder ->build ($ imageArguments );
98+ foreach ($ images as $ imageData ) {
99+ $ imageMiscParams = $ this ->imageParamsBuilder ->build ($ imageData );
100100
101- if (isset ($ imageMiscParams ['image_type ' ])) {
102- unset($ imageMiscParams ['image_type ' ]);
103- }
101+ if (isset ($ imageMiscParams ['image_type ' ])) {
102+ unset($ imageMiscParams ['image_type ' ]);
103+ }
104104
105- $ cacheId = $ this ->encryptor ->hash (
106- implode ('_ ' , $ this ->convertImageMiscParamsToReadableFormat
107- ->convertImageMiscParamsToReadableFormat ($ imageMiscParams )),
108- Encryptor::HASH_VERSION_MD5
109- );
105+ $ cacheId = $ this ->encryptor ->hash (
106+ implode ('_ ' , $ this ->convertImageMiscParamsToReadableFormat
107+ ->convertImageMiscParamsToReadableFormat ($ imageMiscParams )),
108+ Encryptor::HASH_VERSION_MD5
109+ );
110110
111- $ catalogPath = $ this ->mediaConfig ->getBaseMediaPath ();
111+ $ catalogPath = $ this ->mediaConfig ->getBaseMediaPath ();
112112
113- foreach ($ files as $ filePath ) {
114- $ this ->mediaDirectory ->delete (
115- $ catalogPath . '/cache/ ' . $ cacheId . '/ ' . $ filePath
116- );
113+ foreach ($ files as $ filePath ) {
114+ $ this ->mediaDirectory ->delete (
115+ $ catalogPath . '/cache/ ' . $ cacheId . '/ ' . $ filePath
116+ );
117+ }
117118 }
118119 }
119120 }
0 commit comments