VirtoCommerce / vc-storefront

Virto Commerce Storefront - ASP.NET Core 8.0

Home Page:http://virtocommerce.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue After update platform 3.240 auto rest into storefront

Koshalgarg155 opened this issue · comments

Please provide detailed information about your issue, thank you!
I have updated my platform from 3.66 to 3.240. After That i generated auto rest of latest modules. After generating it i am facing issue with 2 mothods of auto rest

Version info:

  • Platform version: 3.240

Issue 1 :- In storefront StoreService.cs file we have method GetAllStoresAsync and this is the code here it have GetStoresAsync in old modules but in new store module there is no api for GetStoresAsync i have also check latest storefront of virto. I think auto rest is also not updated there. So what can we do here to handle this case
public async Task<Model.Stores.Store[]> GetAllStoresAsync()
{
var cacheKey = CacheKey.With(GetType(), "GetAllStoresAsync");
return await _memoryCache.GetOrCreateExclusiveAsync(cacheKey, async (cacheEntry) =>
{
cacheEntry.AddExpirationToken(StoreCacheRegion.CreateChangeToken());
cacheEntry.AddExpirationToken(_apiChangesWatcher.CreateChangeToken());

            var storeDtos = await _storeApi.GetStoresAsync();
            return await Task.WhenAll(storeDtos.Select(x => ConvertStoreAndLoadDependeciesAsync(x)));
        }, cacheNullValue: false);
    }

Issue 2 :- in Storefront SitemapController.cs There is method Try GetSiteMapStream

    private async Task<Stream> TryGetSitemapStream(string filePath)
    {
        //If sitemap files have big size for generation on the fly you might place already generated xml files in the theme/assets folder or schedule 
        // execution of GenerateSitemapJob.GenerateStoreSitemap method for pre-generation sitemaps  
        var stream = await _liquidThemeEngine.GetAssetStreamAsync(filePath);
        if (stream == null)
        {
            var absUrl = UrlBuilder.ToAppAbsolute("~/", WorkContext.CurrentStore, WorkContext.CurrentLanguage);
            var storeUrl = new Uri(WorkContext.RequestUrl, absUrl).ToString();
            //remove language from base url SitemapAPI will add it automatically
            storeUrl = storeUrl.Replace("/" + WorkContext.CurrentLanguage.CultureName + "/", "/");
            stream = await _siteMapApi.GenerateSitemapAsync(WorkContext.CurrentStore.Id, storeUrl, filePath) as Stream;
        }
        return stream;
    }

in this after generation auto rest i am facing conversion issue. in when we are calling await _siteMapApi.GenerateSitemapAsync . Its returning string but its expecting stream in old modules it was returning stream. In new sitemap module its returning string

Steps to reproduce

  1. generate the auto rest for latest modules in storefront
  2. then try to build you will see two issue in auto rest

Hello, @Koshalgarg155 !
Thank you for your appeal!
Please use the workaround below:

We can offer workaround, if you download swagger.json and change this section from application/x-www-form-urlencoded to application/json-patch+json, no more errors.

image

I attached fixed swagger and output files.
Fixes.zip

If the problem persists, please let us know.

Hi @Dan-BV ,
Where do we have to find swagger.json? I don't see it in the storefront
and the issue is with StoreModuleApi and SitemapModuleApi Why do we have to fix the PlatformModuleApi

Thank you for the response

Hi @OlegoO @Dan-BV,
Please check this issue and suggest some solutions regarding these storefront auto rest issues

@Koshalgarg155 We removed GetStores from schema. The method was marked as obsolete, replace service implementation on SearchStoresAsync (POST api/stores/search instead)

Please check how we replaced implementation in API
https://github.com/VirtoCommerce/vc-module-store/blob/dev/src/VirtoCommerce.StoreModule.Web/Controllers/Api/StoreModuleController.cs#L80