how show category image if product has not image

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 年 前
hi
how show category image if product has not image ?
3 年 前
313awaits wrote:
hi
how show category image if product has not image ?


Hello awaits,
With customisation you have to Customise GetPicturesByProductId() method in picture service.
Or if you are using plugin then you have to override this method.


public virtual IList<Picture> GetPicturesByProductId(int productId, int recordsToReturn = 0)
        {
            if (productId == 0)
                return new List<Picture>();

            var query = from p in _pictureRepository.Table
                        join pp in _productPictureRepository.Table on p.Id equals pp.PictureId
                        orderby pp.DisplayOrder, pp.Id
                        where pp.ProductId == productId
                        select p;

            if (recordsToReturn > 0)
                query = query.Take(recordsToReturn);
                        
            var pics = query.ToList();
            
            // Customise code
            if (pics.Count == 0)
            {
                pics = (from p in _pictureRepository.Table
                             join c in _categoryRepository.Table on p.Id equals c.PictureId
                             join cpm in _productCategoryMappingRepository on c.Id equals cpm.categoryId
                             where cpm.ProductId == productId
                             select p).ToList();
            }
           // Customise code
            return pics;
        }
3 年 前
very thnks bro .
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.