how can i add the manufacturer logo in manufacturer template page

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
9 years ago
hi i tried to add the
manufacturer logo in manufacturer template page
by inserting
   <img alt="@Model.PictureModel.AlternateText" src="@Model.PictureModel.ImageUrl" title="@Model.PictureModel.Title" /></a>

but it didnt work.

the same code is used in the all manufacture page in loop ?

any one knows how to fix it?
9 years ago
Hi,

first you should populate PictureModel for manufacturer model. To do this add the following code to the Manufacturer method of the CatalogController:

            
//prepare picture model
            int pictureSize = 100;
            var categoryPictureCacheKey = string.Format(ModelCacheEventConsumer.MANUFACTURER_PICTURE_MODEL_KEY, manufacturer.Id, pictureSize, true, _workContext.WorkingLanguage.Id, _webHelper.IsCurrentConnectionSecured(), _storeContext.CurrentStore.Id);
            model.PictureModel = _cacheManager.Get(categoryPictureCacheKey, () =>
            {
                var pictureModel = new PictureModel()
                {
                    FullSizeImageUrl = _pictureService.GetPictureUrl(manufacturer.PictureId),
                    ImageUrl = _pictureService.GetPictureUrl(manufacturer.PictureId, pictureSize),
                    Title = string.Format(_localizationService.GetResource("Media.Category.ImageLinkTitleFormat"), manufacturer.Name),
                    AlternateText = string.Format(_localizationService.GetResource("Media.Category.ImageAlternateTextFormat"), manufacturer.Name)
                };
                return pictureModel;
            });



And then you can use

<img alt="@Model.PictureModel.AlternateText" src="@Model.PictureModel.ImageUrl" title="@Model.PictureModel.Title" />

in the ManufacturerTemplate.ProductsInGridOrLines.cshtml
9 years ago
tnx
5 years ago
Mariann wrote:
Hi,

first you should populate PictureModel for manufacturer model. To do this add the following code to the Manufacturer method of the CatalogController:

            
//prepare picture model
            int pictureSize = 100;
            var categoryPictureCacheKey = string.Format(ModelCacheEventConsumer.MANUFACTURER_PICTURE_MODEL_KEY, manufacturer.Id, pictureSize, true, _workContext.WorkingLanguage.Id, _webHelper.IsCurrentConnectionSecured(), _storeContext.CurrentStore.Id);
            model.PictureModel = _cacheManager.Get(categoryPictureCacheKey, () =>
            {
                var pictureModel = new PictureModel()
                {
                    FullSizeImageUrl = _pictureService.GetPictureUrl(manufacturer.PictureId),
                    ImageUrl = _pictureService.GetPictureUrl(manufacturer.PictureId, pictureSize),
                    Title = string.Format(_localizationService.GetResource("Media.Category.ImageLinkTitleFormat"), manufacturer.Name),
                    AlternateText = string.Format(_localizationService.GetResource("Media.Category.ImageAlternateTextFormat"), manufacturer.Name)
                };
                return pictureModel;
            });



And then you can use

<img alt="@Model.PictureModel.AlternateText" src="@Model.PictureModel.ImageUrl" title="@Model.PictureModel.Title" />

in the ManufacturerTemplate.ProductsInGridOrLines.cshtml

Still works like a charm in nopCommerce 4.0. Thanks for this!
4 years ago
Mariann wrote:
Hi,

first you should populate PictureModel for manufacturer model. To do this add the following code to the Manufacturer method of the CatalogController:

            
//prepare picture model
            int pictureSize = 100;
            var categoryPictureCacheKey = string.Format(ModelCacheEventConsumer.MANUFACTURER_PICTURE_MODEL_KEY, manufacturer.Id, pictureSize, true, _workContext.WorkingLanguage.Id, _webHelper.IsCurrentConnectionSecured(), _storeContext.CurrentStore.Id);
            model.PictureModel = _cacheManager.Get(categoryPictureCacheKey, () =>
            {
                var pictureModel = new PictureModel()
                {
                    FullSizeImageUrl = _pictureService.GetPictureUrl(manufacturer.PictureId),
                    ImageUrl = _pictureService.GetPictureUrl(manufacturer.PictureId, pictureSize),
                    Title = string.Format(_localizationService.GetResource("Media.Category.ImageLinkTitleFormat"), manufacturer.Name),
                    AlternateText = string.Format(_localizationService.GetResource("Media.Category.ImageAlternateTextFormat"), manufacturer.Name)
                };
                return pictureModel;
            });



And then you can use

<img alt="@Model.PictureModel.AlternateText" src="@Model.PictureModel.ImageUrl" title="@Model.PictureModel.Title" />

in the ManufacturerTemplate.ProductsInGridOrLines.cshtml


Hi,
Could you please let me know what changes has to be done to use your code in Version 4.2 Beta.

Thanks in Advance
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.