public string GetProductViewedScript(ProductDetailsModel model) { var segmentProduct = new SegmentProduct { ProductId = $"{model.Id}", Sku = model.Sku, Category = _categoryService.GetProductCategoriesByProductId(model.Id).FirstOrDefault()?.Category.Name, Name = model.Name, Brand = model.ProductManufacturers.FirstOrDefault(x => x.IsActive)?.Name, Price = model.ProductPrice.PriceValue, Currency = model.ProductPrice.CurrencyCode, ImageUrl = model.DefaultPictureModel.ImageUrl, Url = model.SeName }; return(segmentProduct.GetScript(EcommerceEvent.PRODUCT_VIEWED)); }
public void SetUpdateCartItemToSession(ShoppingCartItem sci) { if (sci.ShoppingCartType == ShoppingCartType.Wishlist) { return; } var segmentProduct = new SegmentProduct { CartId = $"{sci.Id}", ProductId = $"{sci.ProductId}", Sku = sci.Product.Sku, Category = _categoryService.GetProductCategoriesByProductId(sci.ProductId).FirstOrDefault()?.Category.Name, Name = sci.Product.Name, Brand = _manufacturerService.GetProductManufacturersByProductId(sci.ProductId).FirstOrDefault()?.Manufacturer.Name, Price = sci.Product.Price, Quantity = sci.Quantity, Value = sci.Quantity * sci.Product.Price }; _httpContextAccessor.HttpContext.Session.Set(SessionObjectsName.PRODUCT_ADD, segmentProduct); }