Tuesday, September 7, 2021

_varient drop down manualy select Holzpitcher Project

  on Customization user able to click view 


_variantDropdown

@model ProductViewModel
@using Sana.Commerce.Catalog;
@using Sana.Commerce.Shop
@using Sana.Commerce.Customization.ExtendedModels
 
@{
    var variants = Model.Product.Variants;
    var firstGroup = Model.Product.VariantComponents.FirstOrDefault();
    var showPrices = Shop.UserAbilities.Has(AbilityTo.ViewPrices);
    var showStock = Shop.UserAbilities.Has(AbilityTo.ViewStock);
 
    var type = Shop.Settings.ActionPricesPresentationType;
 
    // scope not defined 
    //var selectedVarientId = variants.Where(x => ((ExtendedProductVariant)x).IsSelectedVariant == true).FirstOrDefault();
        
 
    var showListPrice = showPrices &&
(type.iEquals(WebsiteSettings.ActionPricePresentationModes.BaseAndSalesPrice)
|| type.iEquals(WebsiteSettings.ActionPricePresentationModes.BaseAndSalesPriceDiscountPercentage)
|| type.iEquals(WebsiteSettings.ActionPricePresentationModes.BaseAndSalesPriceDiscountAmount));
 
    var showDiscountAmount = showPrices &&
                            (type.iEquals(WebsiteSettings.ActionPricePresentationModes.SalesPriceDiscountAmount)
                            || type.iEquals(WebsiteSettings.ActionPricePresentationModes.BaseAndSalesPriceDiscountAmount));
 
    var showDiscountPercent = showPrices &&
                              (type.iEquals(WebsiteSettings.ActionPricePresentationModes.BaseAndSalesPriceDiscountPercentage)
                              || type.iEquals(WebsiteSettings.ActionPricePresentationModes.SalesPriceDiscountPercentage));
}
 
@if (firstGroup == null)
{
    @DropdownFormRow("variantId"showPricesshowListPriceshowDiscountAmountshowDiscountPercentshowStocknullvariants"withoutgroup")
}
else if (Model.Product.VariantComponents.Count == 1)
{
    @DropdownFormRow("variantId"showPricesshowListPriceshowDiscountAmountshowDiscountPercentshowStockfirstGroupvariants"single")
}
else
{
    string ddId = "c" + Next();
    @DropdownFormRow(ddIdshowPricesshowListPriceshowDiscountAmountshowDiscountPercentshowStockfirstGroupvariants"multifirst")
    var combinations = InitialCombinations(firstGroupvariants);
    foreach (var group in Model.Product.VariantComponents.Skip(1).Take(Model.Product.VariantComponents.Count - 2))
    {
        ddId = "c" + Next();
        @DropdownFormRow(ddIdshowPricesshowListPriceshowDiscountAmountshowDiscountPercentshowStockgroupvariants"multimiddle"combinations)
        combinations = ExpandCombinations(combinationsgroup);
    }
    var lastGroup = Model.Product.VariantComponents.Last();
    @DropdownFormRow("variantId"showPricesshowListPriceshowDiscountAmountshowDiscountPercentshowStocklastGroupvariants"multilast"combinations)
}
 
@helper DropdownFormRow(string ddIdbool showPricesbool showListPricebool showDiscountAmountbool showDiscountPercentbool showStockIVariantComponentGroup groupIProductVariantCollection variantsstring modeIList<dynamiccombinations = null)
{
    <div class="form-row row-variant">
        <div class="control">
            <div class="label">
                <label for="@ddId">@VariantComponentGroupName(group)</label>
            </div>
            <div class="field">
                <div class="ddlb ddlb-component">
                    @if (mode == "withoutgroup")
                    {
                        <select name="@ddId" id="@ddId">
                            @Html.Each(variants,
                                                    @<option value="@item.Id" data-price="@GetPrice(itemshowPrices)"
                                                             data-listprice="@GetListPrice(itemshowListPrice)"
                                                             data-inventory="@When(showStockitem.Inventory.ToString())"
                                                             data-image-tags="@TagBuilder.CreateSanitizedId('v' + item.Id)"
                                                             data-discount-percentage="@GetDiscountPercantage(itemshowDiscountPercent)"
                                                             data-discount-amount="@GetDiscountAmount(itemshowDiscountAmount)"
                                                             data-available-sales-agreement-lines="@item.AvailableSalesAgreementLines.ToJson().ToHtmlString()"
                                                             @When(!item.IsOrderable, "data-not-orderable")>
                                                        @item.Title.Or(item.Id)
                                                    </option>)
                        </select>
                    }
                    else if (mode == "single")
                    {
                        <select name="@ddId" id="@ddId">
                            @Html.Each(group.Items.Select(i => variants.FirstOrDefault(v => v.Components.Match(group.Id, i.Id))).Where(v => v != null),
                                                    @<option value="@item.Id" data-price="@GetPrice(itemshowPrices)"
                                                             data-listprice="@GetListPrice(itemshowListPrice)"
                                                             data-inventory="@When(showStockitem.Inventory.ToString())"
                                                             data-image-tags="@TagBuilder.CreateSanitizedId('v' + item.Id) @TagBuilder.CreateSanitizedId('v' + item.Components[group.Id])"
                                                             data-discount-percentage="@GetDiscountPercantage(itemshowDiscountPercent)"
                                                             data-discount-amount="@GetDiscountAmount(itemshowDiscountAmount)"
                                                             data-available-sales-agreement-lines="@item.AvailableSalesAgreementLines.ToJson().ToHtmlString()"
                                                             @When(!item.IsOrderable, "data-not-orderable")>
                                                        @group.Items[item.Components[group.Id]].Name
                                                    </option>)
                        </select>
                    }
                    else if (mode == "multifirst")
                    {
                        // 3.3 issue Set selected drop down
                        var selectedVarient = variants.Where(x => ((ExtendedProductVariant)x).IsSelectedVariant == true).FirstOrDefault();
 
                        if (selectedVarient != null)
                        {
                            var selectedVarientComponent = group.Items.FilterByVariants(new List<IProductVariant>() { selectedVarient }).FirstOrDefault();
                            var comId = selectedVarientComponent.Id;
 
                            @Html.DropDownList(ddIdgroup.Items.FilterByVariants(variants).Select(c => new SelectListItem { Value = c.Id, Text = c.Name, Selected = (c.Id == comId) }))
                        }
                        else
                        {
                            @Html.DropDownList(ddIdgroup.Items.FilterByVariants(variants).Select(c => new SelectListItem { Value = c.Id, Text = c.Name }))
                        }
                    }
                    else if (mode == "multimiddle")
                    {
                        <select name="@ddId" id="@ddId">
                            @foreach (var scope in combinations)
                            {
                                var selectedVarient = variants.Where(x => ((ExtendedProductVariant)x).IsSelectedVariant == true).FirstOrDefault();
                                if (selectedVarient != null)
                                {
 
                                    var selectedVarientComponent = group.Items.FilterByVariants(new List<IProductVariant>() { selectedVarient }).FirstOrDefault();
                                    var comId = selectedVarientComponent.Id;
 
                                    var ss = (IList<IProductVariant>)scope.Variants;
                                    //var selectedVarientComponent = group.Items.FilterByVariants(new List<IProductVariant>() { selectedVarient }).FirstOrDefault();
                                }
 
                                var items = group.Items.FilterByVariants((IList<IProductVariant>)scope.Variants);
                                <optgroup label="@scope.Text" data-scope="@scope.Key">
                                    @Html.Each(items@<option value="@scope.Key @item.Id">@item.Name</option>)
                                </optgroup>
                            }
                        </select>
                    }
                    else if (mode == "multilast")
                    {
 
                        var selectedVarient = variants.Where(x => ((ExtendedProductVariant)x).IsSelectedVariant == true).FirstOrDefault();
                        if (selectedVarient != null)
                        {
 
                        }
 
                        <select name="@ddId" id="@ddId">
                            @foreach (var scope in combinations)
                            {
                                var vars = (IList<IProductVariant>)scope.Variants;
                                <optgroup label="@scope.Text" data-scope="@scope.Key">
                                    @foreach (var item in group.Items)
                                    {
                                        var variant = vars.FirstOrDefault(v => v.Components.Match(group.Id, item.Id));
                                        if (variant != null)
                                        {
                                            var selectedValue = "";
 
                                            //if (variant.Id == selectedVarient.Id)
                                            //{
                                            //    selectedValue = "selected";
                                            //}
 
                                            <option @selectedValue
                                                    value="@variant.Id" data-price="@GetPrice(variantshowPrices)"
                                                    data-listprice="@GetListPrice(variantshowListPrice)"
                                                    data-inventory="@When(showStockvariant.Inventory.ToString())"
                                                    data-image-tags="@TagBuilder.CreateSanitizedId('v' + variant.Id) @variant.Components.Values.Select(v => TagBuilder.CreateSanitizedId('v' + v)).JoinWith(" ")"
                                                    data-discount-percentage="@GetDiscountPercantage(variantshowDiscountPercent)"
                                                    data-discount-amount="@GetDiscountAmount(variantshowDiscountAmount)"
                                                    data-available-sales-agreement-lines="@variant.AvailableSalesAgreementLines.ToJson().ToHtmlString()"
                                                    @When(!variant.IsOrderable, "data-not-orderable")>
                                                @item.Name
                                            </option>
                                        }
                                    }
                                </optgroup>
                            }
                        </select>
                    }
                </div>
            </div>
        </div>
    </div>
}
 
@functions
{
    string GetPrice(Sana.Commerce.Catalog.IProductVariant variantbool showPrices)
    {
        if (!showPrices)
            return null;
 
        return variant.Price.FormatAsPrice();
    }
 
    string GetListPrice(Sana.Commerce.Catalog.IProductVariant variantbool showPrices)
    {
        if (!showPrices)
            return null;
 
        if (variant.ListPrice == null)
            return string.Empty;
 
        return variant.ListPrice.Value.FormatAsPrice();
    }
 
    string GetDiscountPercantage(Sana.Commerce.Catalog.IProductVariant variantbool showPrices)
    {
        if (!showPrices)
            return null;
 
        return ProductExtensions.DiscountPercentage(variant.Price, variant.ListPrice, Shop.CommerceContext.CurrencyId).ToHtmlString();
    }
 
    string GetDiscountAmount(Sana.Commerce.Catalog.IProductVariant variantbool showPrices)
    {
        if (!showPrices)
            return null;
 
        return ProductExtensions.DiscountAmount(variant.Price, variant.ListPrice, Shop.CommerceContext.CurrencyId).ToHtmlString();
    }
 
    IHtmlString VariantComponentGroupName(IVariantComponentGroup group)
    {
        return group == null ? Sana.SimpleText("Variant": Sana.SimpleText("Product_VariantComponent_" + group.Id, group.Name);
    }
 
    IList<dynamicInitialCombinations(IVariantComponentGroup groupIList<IProductVariantvariants)
    {
        return ExpandCombinations(new[] { new { Key = string.Empty, Variants = variants } }, group);
    }
 
    IList<dynamicExpandCombinations(IList<dynamiccurrentIVariantComponentGroup group)
    {
        var result = new List<dynamic>();
        foreach (var parent in current)
        {
            var variants = (IList<IProductVariant>)parent.Variants;
            foreach (var item in group.Items.FilterByVariants(variants))
            {
                result.Add(new
                {
                    Key = parent.Key != string.Empty ? parent.Key + ' ' + item.Id : item.Id,
                    Text = parent.Key != string.Empty ? parent.Text + '-' + item.Name : item.Name,
                    Variants = variants.Where(v => v.Components.Match(group.Id, item.Id)).ToArray()
                });
            }
        }
        return result;
    }
 
}

Ticket 93818: [Holz Pichler] 3.3. Item variants – “range value” attributes.



revert / undo shop creatrion sql

    begin transaction


DECLARE @newWebsiteId nvarchar(50);

DECLARE @newWebsiteName nvarchar(50);

DECLARE @newWebsiteDomain nvarchar(50);


--SET @newWebsiteId = N'SANA_CH'; -- set a new website ID instead of 'NewWebsiteID'

--SET @newWebsiteName = N'SANA_CH'; -- set the name of the new website instead of 'New Website Name'

--SET @newWebsiteDomain = N'ravensburger-ch-beta.sanastores.net'; -- set the domain for new website instead of 'localhost'

--SELECT @defaultLanguage = Id FROM [Languages] WHERE [IsDefault] = 1;


 -- delete from [Websites] where id ='SANA_CH' -- @newWebsiteId

-- delete from [WebsiteLanguages] where [WebsiteId] ='SANA_CH' -- @newWebsiteId :: done

-- delete from  FederalMerchants_935.[dbo].[WebsiteDomains]  where [WebsiteId] = 'SANA_CH' :: done


 -- d-elete  AdminUsers manualy :: done

  --delete from FederalMerchants_935.[dbo].[FlexiPages] where [WebsiteId] = 'SANA_CH' --@newWebsiteId :: done

  --delete from FederalMerchants_935.[dbo].[Settings] where [WebsiteId] = 'SANA_CH' --@newWebsiteId :: done

language packs

  packes

https://community.sana-commerce.com/translations/versions


to install language to front end side , 

admin  app > lanuage > configuration > 

1 upload correct lanuage pack save 

2 need to do app pool restart. after the install package.


To install language to admin side , 

D:\Project docs\lanuages\Change Language of Sana Admin



CHANGE LANGUAGE OF THE SANA ADMIN

·        Download the required Language from below link
Note : Select the Language pack from the “Admin Language Packs” section
-https://community.sana-commerce.com/translations/versions

 

·        Extract the Folder (following files will be there)



·        Step 1: Copy the “Admin” resource file from the “AdminResources” folder in the language pack and replace the one in the Sana Commerce frontend directory:

Frontend\App_Data\content\files\images\languages

 

·        Step 2 : Copy the Language pack icon from content folder to frontend directory :

Frontend\App_Data\AdminResources

·        Step 3: Execute the “Add language script Admin.sql” script on the Sana Commerce database. When the language pack is installed the language of the Sana Admin interface will be changed.


Open PDF doc in new tab without showing download popup.

  Project :PRL glass 

Ticket 102771: [PRL Glass] 3.3. Download Customer Statement report from My Account
Response.SetCookie(new HttpCookie("fileDownload""true") { HttpOnly = false });                       
                      
          Response.Buffer = true;
          Response.ContentType = "application/pdf";
 
          Response.AppendHeader("Content-Disposition""inline; filename=" + reportname + ".pdf");
 
          Response.Cache.SetCacheability(HttpCacheability.NoCache);
          Response.OutputStream.Write(memoryStreamReport0memoryStreamReport.Length);
 
          Response.End();


View\Default\Profile\Index.cshtml

// Ticket 102771: [PRL Glass] 3.3. Download Customer Statement report from My Account
            // Add Button with and set target = "_blank" to open in new window.
            @Sana.LinkButton(textKeyreportName.ToString(),
               url: Url.Action("CustomerStatmentReport""ErpFileDownload"new { customerId = customerId.ToString() }),
               cssClass"btn btn-report"defaultTextreportName.ToString(), htmlAttributesnew { rel = "nofollow", target = "_blank" })
           



public class ExtendedErpFileDownloadController : ErpFileDownloadController
    {
        protected override void RegisterSystemRoutes(SanaRouteCollection routes)
        {
            base.RegisterSystemRoutes(routes);
 
            // Ticket 102771: [PRL Glass] 3.3. Download Customer Statement report from My Account
            routes.MapSystemPageRoute(Name, "CustomerStatmentReport""CustomerStatmentReport""CustomerStatmentReport/files/Customer-Statment-Report.pdf");
        }
 
        // Ticket 102771: [PRL Glass] 3.3. Download Customer Statement report from My Account
        /// <summary>
        /// A GET action to get the customer statment report.
        /// </summary>
        /// <param name="customerId">The customer ID.</param> 
        /// <returns>Returns the order report.</returns>
        [Authorize]
        [HttpGet]
        public virtual ActionResult CustomerStatmentReport(string customerIdint maxTimeoutExceptionSkips = 5int sleepDurationBetweenAttempts = 10000)
        {
            if (customerId.IsEmptyString())
                return HttpNotFound();            
 
            Stream reportStream = null;
            var retryCount = maxTimeoutExceptionSkips;
            while (true)
            {
                try
                {
                    reportStream = ((ExtendedAttachmentApi)ShopApi.Attachments).LoadCustomerStatmentReport(customerId);
                }
                catch (SanaConnectionException ex)
                {
                    if (ex.InnerException == null || !(ex.InnerException is TimeoutException))
                        throw;
                    if (retryCount == 0)
                        throw;
                    Thread.Sleep(sleepDurationBetweenAttempts);
                    retryCount--;
                    continue;
                }
                break;
            }
 
            if (reportStream == null)
                return new HttpNotFoundResult();
            
            //Set report name.
            var reportname = "CustomerStatmentReport_" + customerId;
            
            //Get bytes from stream.
            var memoryStreamReport = ((MemoryStream)reportStream).ToArray();
 
            Response.SetCookie(new HttpCookie("fileDownload""true") { HttpOnly = false });
 
            Response.Buffer = true;
            Response.ContentType = "application/pdf";
            Response.AppendHeader("Content-Disposition""inline; filename=" + reportname + ".pdf");
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.OutputStream.Write(memoryStreamReport0memoryStreamReport.Length);
            Response.End();
 
            return File(reportStream, System.Net.Mime.MediaTypeNames.Application.Pdf, reportname);            
        }
 
    }











_varient drop down manualy select Holzpitcher Project

  on Customization user able to click view  _variantDropdown @model  ProductViewModel @ using  Sana . Commerce . Catalog; @ using  Sana . C...