nmt88 wrote:Hi,
I'm looking for the exact same thing (for a photography gallery shop).
Are there any tutorials for mapping customers to categories or products?
Thanks,
Hi
I made a small change to the code.
CustomerID must be written in Admin Comments Textfield under the product.
If customer with correct ID is logged in the image will display otherwise the image is not shown.
If Admin Comments is blank the product will show for everyone.
Simple change that works for me but it can be improved if needed.
The code is located at presentation\Nop.Web\Controllers\CatalogController.cs (Line 304)
private ProductModel PrepareProductOverviewModel(Product product, bool preparePriceModel = true, bool preparePictureModel = true)
{
if (product == null)
throw new ArgumentNullException("product");
var model = product.ToModel();
//price
if (preparePriceModel)
{
model.ProductPrice = PrepareProductPriceModel(product);
}
//picture
if (preparePictureModel)
{
var picture = product.GetDefaultProductPicture(_pictureService);
// Added By Tommy Christensen 16-11-2011
Int32 findID = Convert.ToInt32(product.AdminComment);
if (findID < 1)
findID = 0;
// Add end
// if (picture != null) Removed by Tommy Christensen
if (picture != null && _workContext.CurrentCustomer.Id == findID || picture != null && findID==0)// Added by Tommy Christensen
model.DefaultPictureModel.ImageUrl = _pictureService.GetPictureUrl(picture, _mediaSetting.ProductThumbPictureSize, true);
else
model.DefaultPictureModel.ImageUrl = _pictureService.GetDefaultPictureUrl(_mediaSetting.ProductThumbPictureSize);
model.DefaultPictureModel.Title = string.Format(_localizationService.GetResource("Media.Product.ImageLinkTitleFormat"), model.Name);
model.DefaultPictureModel.AlternateText = string.Format(_localizationService.GetResource("Media.Product.ImageAlternateTextFormat"), model.Name);
}
return model;
}