public IViewComponentResult Invoke(EditorPageModel editorPageModel) { var result = ProductDetailsAfterBreadcrumb(editorPageModel); if (result != null) { return(result); } return(Content("")); }
public IViewComponentResult ProductDetailsAfterBreadcrumb(EditorPageModel editorPageModel) { var productId = editorPageModel.ProductId; var quantity = editorPageModel.Quantity; var updateCartItemId = editorPageModel.UpdateCartItemId; var id = productId; var product = _productService.GetProductById(id); if (product != null && _ccService.IsProductForCc(product)) { var editorName = _ccService.GetEditorDefinition(product); var configName = _ccService.GetEditorConfiguration(product); var editorJsonData = _ccService.GetEditor(editorName); var settings = _settingService.LoadSetting <CcSettings>(); settings.CustomersCanvasApiKey = ""; settings.OrderExportPath = ""; settings.DesignFileName = ""; var model = new CcEditorLoaderModel { PluginSettings = settings, ProductDetails = GetProductDetails(id, updateCartItemId), ProductId = id, Editor = editorJsonData.ToJson(), Config = editorJsonData.GetConfigByTitle(configName).ToJson(), Path = editorJsonData.VirtualPath, EditorFolder = editorJsonData.FolderName, UpdateCartItemId = updateCartItemId, CcData = null, Quantity = quantity, Language = _workContext.WorkingLanguage.LanguageCulture.Split('-')[0], Currency = new CurrencyModel() { Code = _workContext.WorkingCurrency.CurrencyCode, Locale = _workContext.WorkingLanguage.LanguageCulture } }; model.ProductDetails.PageShareCode = ""; var userModel = new UserModel(); userModel.UserGuid = _workContext.CurrentCustomer.CustomerGuid.ToString().Replace("-", ""); userModel.UserId = _workContext.CurrentCustomer.Id; userModel.IsAuthenticated = User.Identity.IsAuthenticated; model.User = userModel; if (updateCartItemId != 0) { var ccIdAttribute = model.ProductDetails.ProductAttributes.FirstOrDefault(x => x.ProductAttributeId == _customersCanvasSettings.CcIdAttributeId); int designId = 0; if (ccIdAttribute != null) { if (Int32.TryParse(ccIdAttribute.DefaultValue, out designId)) { model.CcData = _ccService.GetDesign(designId); } } } return(View("~/Plugins/Widgets.CustomersCanvas/Views/Product/EditorScripts.cshtml", model)); } return(null); }