@@ -85,6 +85,40 @@ public virtual void DeleteCheckoutAttribute(CheckoutAttribute checkoutAttribute)
8585 _eventPublisher . EntityDeleted ( checkoutAttribute ) ;
8686 }
8787
88+ /// <summary>
89+ /// Gets checkout attributes
90+ /// </summary>
91+ /// <param name="storeId">Whether to filter result by store identifier</param>
92+ /// <param name="showHidden">A value indicating whether to show hidden records</param>
93+ /// <returns>Checkout attributes query</returns>
94+ public virtual IQueryable < CheckoutAttribute > GetCheckoutAttributes ( int storeId = 0 , bool showHidden = false )
95+ {
96+ var query = _checkoutAttributeRepository . Table ;
97+
98+ if ( ! showHidden )
99+ query = query . Where ( x => x . IsActive ) ;
100+
101+ if ( storeId > 0 && ! QuerySettings . IgnoreMultiStore )
102+ {
103+ query =
104+ from x in query
105+ join sm in _storeMappingRepository . Table on new { c1 = x . Id , c2 = "CheckoutAttribute" } equals new { c1 = sm . EntityId , c2 = sm . EntityName } into x_sm
106+ from sm in x_sm . DefaultIfEmpty ( )
107+ where ! x . LimitedToStores || storeId == sm . StoreId
108+ select x ;
109+
110+ query =
111+ from x in query
112+ group x by x . Id into grp
113+ orderby grp . Key
114+ select grp . FirstOrDefault ( ) ;
115+ }
116+
117+ query = query . OrderBy ( x => x . DisplayOrder ) ;
118+
119+ return query ;
120+ }
121+
88122 /// <summary>
89123 /// Gets all checkout attributes
90124 /// </summary>
@@ -97,32 +131,10 @@ public virtual IList<CheckoutAttribute> GetAllCheckoutAttributes(int storeId = 0
97131
98132 return _cacheManager . Get ( key , ( ) =>
99133 {
100- var query = _checkoutAttributeRepository . Table ;
101-
102- if ( ! showHidden )
103- query = query . Where ( x => x . IsActive ) ;
104-
105- if ( storeId > 0 && ! QuerySettings . IgnoreMultiStore )
106- {
107- query =
108- from x in query
109- join sm in _storeMappingRepository . Table on new { c1 = x . Id , c2 = "CheckoutAttribute" } equals new { c1 = sm . EntityId , c2 = sm . EntityName } into x_sm
110- from sm in x_sm . DefaultIfEmpty ( )
111- where ! x . LimitedToStores || storeId == sm . StoreId
112- select x ;
113-
114- query =
115- from x in query
116- group x by x . Id into grp
117- orderby grp . Key
118- select grp . FirstOrDefault ( ) ;
119- }
120-
121- query = query . OrderBy ( x => x . DisplayOrder ) ;
122-
123- var checkoutAttributes = query . ToList ( ) ;
124- return checkoutAttributes ;
125- } ) ;
134+ var query = GetCheckoutAttributes ( storeId , showHidden ) ;
135+
136+ return query . ToList ( ) ;
137+ } ) ;
126138 }
127139
128140 /// <summary>
0 commit comments