@@ -444,14 +444,15 @@ public NBrightInfo GetOptionValue(String optionid, String optionvalueid)
444444 /// <summary>
445445 /// Select categories linked to product, by groupref
446446 /// </summary>
447+ /// <param name="portalId"></param>
447448 /// <param name="groupref">groupref for select, "" = all, "cat"= Category only, "!cat" = all non-category, "{groupref}"=this group only</param>
448449 /// <param name="cascade">get all cascade records to get all parent categories</param>
449450 /// <returns></returns>
450- public List < GroupCategoryData > GetCategories ( String groupref = "" , Boolean cascade = false )
451+ public List < GroupCategoryData > GetCategories ( int portalId , String groupref = "" , Boolean cascade = false )
451452 {
452453 if ( Info == null ) return new List < GroupCategoryData > ( ) ; // stop throwing an error no product exists,
453454
454- var objGrpCtrl = new GrpCatController ( _lang ) ;
455+ var objGrpCtrl = new GrpCatController ( _lang , portalId ) ;
455456 var catl = objGrpCtrl . GetProductCategories ( Info . ItemID , groupref , cascade ) ;
456457 if ( Utils . IsNumeric ( DataRecord . GetXmlProperty ( "genxml/defaultcatid" ) ) && catl . Count > 0 )
457458 {
@@ -468,6 +469,19 @@ public List<GroupCategoryData> GetCategories(String groupref = "", Boolean casca
468469 return catl ;
469470 }
470471
472+
473+ /// <summary>
474+ /// Select categories linked to product, by groupref
475+ /// </summary>
476+ /// <param name="groupref">groupref for select, "" = all, "cat"= Category only, "!cat" = all non-category, "{groupref}"=this group only</param>
477+ /// <param name="cascade">get all cascade records to get all parent categories</param>
478+ /// <returns></returns>
479+ public List < GroupCategoryData > GetCategories ( String groupref = "" , Boolean cascade = false )
480+ {
481+ var portalId = PortalSettings . Current . PortalId ;
482+ return GetCategories ( portalId , groupref , cascade ) ;
483+ }
484+
471485 /// <summary>
472486 /// Select properties linked to product, by groupref
473487 /// </summary>
@@ -689,6 +703,7 @@ public void Save(bool triggerevent, bool newrecord)
689703 DataRecord = objCtrl . Get ( productid ) ;
690704 DataLangRecord = objCtrl . Get ( plangid ) ;
691705 }
706+
692707 }
693708
694709 private void UpdateDisplayCalcPrices ( )
@@ -1744,6 +1759,7 @@ public int Validate()
17441759 }
17451760 lp += 1 ;
17461761 }
1762+
17471763 //Fix document paths
17481764 lp = 1 ;
17491765 foreach ( var d in Docs )
@@ -1794,7 +1810,7 @@ public int Validate()
17941810 }
17951811
17961812 // remove duplicate category xrefs.
1797- var catlist = GetCategories ( ) ;
1813+ var catlist = GetCategories ( _portalId ) ;
17981814 foreach ( var c in catlist )
17991815 {
18001816 var l = objCtrl . GetList ( _portalId , - 1 , "CATXREF" , " and NB1.ParentItemId = " + Info . ItemID . ToString ( "" ) + " and NB1.XrefItemId = " + c . categoryid . ToString ( "" ) ) ;
@@ -1835,6 +1851,7 @@ public int Validate()
18351851 objCtrl . Delete ( c . ItemID ) ;
18361852 errorcount += 1 ;
18371853 }
1854+
18381855 // remove catcascade record that have no catxref record for the product.
18391856 var caslist = new List < int > ( ) ;
18401857 var catcascadelist = objCtrl . GetList ( _portalId , - 1 , "CATCASCADE" , " and nb1.ParentItemId = '" + Info . ItemID + "' " ) ;
@@ -1843,10 +1860,10 @@ public int Validate()
18431860 caslist . Add ( n . XrefItemId ) ;
18441861 }
18451862
1846- var catlist2 = GetCategories ( ) ;
1863+ var catlist2 = GetCategories ( _portalId ) ;
18471864 if ( catlist2 . Any ( ) )
18481865 {
1849- var objGrpCtrl = new GrpCatController ( _lang , true ) ;
1866+ var objGrpCtrl = new GrpCatController ( _lang , _portalId , true ) ;
18501867 foreach ( var cat in catlist2 )
18511868 {
18521869 var parentcats = objGrpCtrl . GetCategory ( cat . categoryid ) ;
@@ -1876,10 +1893,9 @@ public int Validate()
18761893 }
18771894 }
18781895
1879-
1880-
18811896 // update shared product if flagged
1882- if ( StoreSettings . Current . GetBool ( "shareproducts" ) && DataRecord . PortalId >= 0 )
1897+ StoreSettings storeSettings = ( System . Web . HttpContext . Current != null ) ? StoreSettings . Current : new StoreSettings ( _portalId ) ;
1898+ if ( storeSettings . GetBool ( "shareproducts" ) && DataRecord . PortalId >= 0 )
18831899 {
18841900 upd = true ;
18851901 DataRecord . PortalId = - 1 ;
@@ -1889,7 +1905,7 @@ public int Validate()
18891905 }
18901906 }
18911907
1892- // check if we have empty model name ()
1908+ // check if we have empty model name
18931909 var modellp = 1 ;
18941910 foreach ( var m in Models )
18951911 {
@@ -1975,13 +1991,11 @@ public int Validate()
19751991 }
19761992 }
19771993
1978-
19791994 return errorcount ;
19801995 }
19811996
19821997 public int Copy ( )
19831998 {
1984-
19851999 var objCtrl = new NBrightBuyController ( ) ;
19862000
19872001 //Copy Base record
@@ -2083,7 +2097,6 @@ public void FillEmptyLanguageFields()
20832097 }
20842098 }
20852099
2086-
20872100 // models
20882101 var nodList1 = DataLangRecord . XMLDoc . SelectNodes ( "genxml/models/genxml" ) ;
20892102 if ( nodList1 != null )
@@ -2214,15 +2227,11 @@ public void FillEmptyLanguageFields()
22142227 }
22152228 }
22162229
2217-
22182230 public void OutputDebugFile ( String filePathName )
22192231 {
22202232 Info . XMLDoc . Save ( filePathName ) ;
22212233 }
22222234
2223-
2224-
2225-
22262235 #endregion
22272236
22282237 #region " private functions"
@@ -2311,7 +2320,6 @@ private void LoadData(int productId, Boolean hydrateLists = true)
23112320
23122321 private int AddNew ( )
23132322 {
2314-
23152323 var nbi = new NBrightInfo ( true ) ;
23162324 if ( StoreSettings . Current . Get ( "shareproducts" ) == "True" ) // option in storesetting to share products created here across all portals.
23172325 _portalId = - 1 ;
@@ -2468,7 +2476,6 @@ public Double GetDealerSalePriceDouble()
24682476 return price ;
24692477 }
24702478
2471-
24722479 private bool CheckClientFileUpload ( )
24732480 {
24742481 return Info . GetXmlPropertyBool ( "genxml/checkbox/chkfileupload" ) ;
0 commit comments