Short Notes

 How to get matching items from two List by LinQ


var CategoryIdList = product.CategoryIds;
var relatedProductItems = ((ExtendedProductManager)CommerceFrameworkBase.Products).GetRelatedProductItems();
          
var relatedProductItemsList = relatedProductItems.Where(m => CategoryIdList.Contains(m.CategoryId)).ToList();

not matching (use (not) ! for statment)

var relatedProductItemsList = relatedProductItems.Where(m => !CategoryIdList.Contains(m.CategoryId)).ToList();

anothr way 

var basketRangeValueFields = ((BasketLine)basketLine).RangeValueList;
                       var machingRangeValueFields = excictingLineRangeValues.Where(x => basketRangeValueFields.Any(y => x.Id == y.Id && x.Value == y.Value)).ToList();
                       var result = (machingRangeValueFields.Count == basketRangeValueFields.Count);


multiple fields check with two list

// Ticket 93818: [Holz Pichler] 3.3.Item variants – “range value” attributes.
            var excictingLineRangeValues = ((BasketLine)line1).RangeValueList;
            var newLineRangeValues = ((BasketLine)line2).RangeValueList;
 
            if (excictingLineRangeValues != null && newLineRangeValues != null)
            {
                var machingRangeValueFields = excictingLineRangeValues.Where(x => newLineRangeValues.Any(y => x.Name == y.Name && x.Id == y.Id && x.Value == y.Value)).ToList();
                var result = (machingRangeValueFields.Count == newLineRangeValues.Count);
                return result;
            }



How to call constant data on Sana admin

Kavo : AdminMenuInitializer.

Topmedia:

CreateAdminMenuLink(Admin.ResourceManager.GetString(Sana.Commerce.Constants.ProductFinder), urlHelper.Action("ProductFinder""ProductIndex"),
                           PermissionOn.SearchSettings)),


Drop Down

<div class="form-group">
    @Html.LabelFor(x => Model.SelectedProductType, htmlAttributes: new { @class = "control-label col-md-2" })
    <br />
    <div class="">
        @Html.DropDownListFor(x => Model.SelectedProductType, new SelectList(Model.ProductTypes, "Code""Name"),
        " Select" , htmlAttributes: new { @class = "form-control", id = "ProductType" })
        @Html.ValidationMessageFor(x => x.SelectedProductType, ""new { @class = "text-danger" })
    </div>
</div>


Website ID

var websiteId = CommerceFrameworkBase.Context.WebsiteId;


reload page by controler 

return Redirect(Request.UrlReferrer.ToString());


Selected Web shop lanuage

var currentLanguage = CommerceFrameworkBase.Context.LanguageId;
var culture = CultureInfo.GetCultureInfo(currentLanguage);


Customer is b2b or b2c
var shopContext = ShopContext.GetCurrent(); 
shopContext.IsB2cCustomer

Loggin time out : 

Add this to Web config File  after two minutes it will logout

 <!--Increase the frontend login session expires time -->
    <add key="FrontendAuthenticationTimeout" value="2" />


Customer segment :

How to identify current customer match with customer segments

eg:Intergria helthcare> ExtendedProductController > UpdateProductTabDescriptions > line97

ShopApi.UserState.IsCurrentUserInSegment(Shop, customerSegmentIndications) 


Add Logs   views

using Sana.Utilities.Logging;
var log = ObjectManager.GetInstance<ILog>();
            log.Add("1.EditOrderTemplate() method : " + "\r\n"); // Log file will remove after test