Unused function parameters in PictureService

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 年 前
NopCommerce Version 3.8 and 3.7

We are trying to extend the PictureService, however, we are noticing that there are a few functions that are getting parameters passed in that are never used.

I am guessing these can be refactored.

Some examples (thumbFileName never used):

protected virtual bool GeneratedThumbExists(string thumbFilePath, string thumbFileName)
{
  return File.Exists(thumbFilePath);
}

protected virtual void SaveThumb(string thumbFilePath, string thumbFileName, byte[] binary)
{
  File.WriteAllBytes(thumbFilePath, binary);
}


Also, there is a function called: GetPictureUrl
In that function, there is this block of code:
if (showDefaultPicture)
{
   url = GetDefaultPictureUrl(targetSize, defaultPictureType, storeLocation);
}


GetDefaultPictureUrl is a very extensive, heavy function.
Can the DefaultPictureUrl be passed in as an optional parameter to GetPictureUrl and only generate the url if the string passed in is null or empty?

For example, when running the Google shopping feed, it already generates this default image url, then when it gets the picture url, the same default url is generated again.  Now image if I have a large volume of products that meet this condition, we are re-generating the same url over and over again.  

Overall the picture service could use optimization, many of the bottle necks during batch processing seem to be impacted by image processing.

Thank you.
7 年 前
Sizzler wrote:
We are trying to extend the PictureService, however, we are noticing that there are a few functions that are getting parameters passed in that are never used.

It's not the bug. We have two classes - PictureService and AzurePictureService. The first parameter is used in one class, the second one in the second file

Sizzler wrote:
GetDefaultPictureUrl is a very extensive, heavy function

That's not true. It's not heavy. It generates a thumb only once. Once it's done then it returns URL of already generated file (see "GeneratedThumbExists" method)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.