an ASP.NET Open Source CMS & eCommerce platform
Search:
Skip Navigation LinksHome > DotShoppingCart Forums > Support > Using DotShoppingCart > Building a Custom Master Detail Entity-Produc...
Last Post 3/7/2010 10:54:02 PM By Bahram. 9 replies.
3/3/2010 3:50:19 PM
Bahram
Posts: 878
Joined: 12/8/2008
Location:Vancouver, BC Canada
Building a Custom Master Detail Entity-Product in DSC
Problem :
 
We have an Entity called Application, each application can have multiple products and a product may occure in more than one application, we want users to view all the products of an application
 
This is what I have done:
 
I chose Manufacturer since it has image and two existing ASP forms
 
1- Created two tables: Application like Manufacturer and another table callled Product_Application_mapping

2- Duplicated these ASP controls ManufactureList.ascx and ManufacturerProducts.ascx and respectively named them ApplicationList.ascx and ApplicationProducts.ascx

3- Added the new blocks to DCS_Block_Type_lkp

INSERT INTO DSC_Block_Type_lkp (type, virtualPath) VALUES ('Application Products', '/Store/ApplicationProducts.ascx')
INSERT INTO DSC_Block_Type_Group_Block_Type_Map (BlockTypeGroupId, BlockTypeId, SortOrder) VALUES (3, 86, 10)

4- Now we have an Application List that is working just Like Manufacturer List

This is it what we need: The ApplicationProduct.ascx shoud shows products for the selected application

Here in Page Load of ApplicationProducts transformed from ManufacuturProducts

protected void Page_Load(object sender, EventArgs e) {

............................

 
        applicationId = Utils.GetIntParameter("mid", 0);
        if (0 == applicationId)
            Response.Redirect(SiteNavigation.Error404Page);
       
        using (DSCComDataContext dc = DSCComDataContext.GetDataContext()) {
            application = dc.Applications.Single(m => m.ApplicationId == applicationId);
        }
       
 
        LoadMetaTags();
 
        int pageNumber = Utils.GetIntParameter("page", 1);
        int productPerPage = applicationProductData.ProductsPerPage;
        int totalNumber = 0;
        List<Product> products = Product.GetProducts(null, productPerPage,
            (pageNumber - 1) * productPerPage, (ProductSortBy)Utils.GetIntParameter("sortby", 0), application.Name,
            Utils.GetNullableDecimalParameter("pricefrom"), Utils.GetNullableDecimalParameter("priceto"),
            StoreConfigurationSection.GetSection().ShowStock, out totalNumber);
 
......
 
    }
 

 

1- I need to have my tables added to DSCComDataSourceDataContext LINQ DataSources

2-Need to have Application metadata just like Manufacturer metadata

3- I need to have a new Product.GetProducts to filter product by this query in detail form

Select P.*
From dbo.DSC_Product P inner join [USI_Application_Product_Map] Ap on P.productId =  Ap.productId
Where Ap.applicationId = @appID

 

Or if you suggest a code that does not require to touch the above DSC resources and is easier.
 

 
3/4/2010 10:58:34 AM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: Building a Custom Master Detail Entity-Product in DSC
1) Add your tables to LinqToSQL data model file DSCCom.dbml
2) Add columns to Application to store the metadata and retreive those back while you are displaying
3) Change Product.GetProducts to add the new filter for Application and change the underline store procedures
 
What is Application anyway? Why cannot you use category?
DotShoppingCart Staff
3/4/2010 11:19:26 AM
Bahram
Posts: 878
Joined: 12/8/2008
Location:Vancouver, BC Canada
Re: Building a Custom Master Detail Entity-Product in DSC
They are totally differrent and independent  :
 
Application is a term used for areas to use devices i.e. Pressure, Humidity ....
a customer may look for a product just by application and not by our product category grouping.
 
while category is the grouping of products according to our ERP system.
we already have Category, Subcategory and Product
 
Example of Categroy-Subcategory- Product :
 
Data Loggers - SmartReaders - Smartreader 1
Data Loggers - SmartReaders - Smartreader 2
Data Loggers - SmartReaders - Smartreader 3
 
Softwares - Packages - Trendreader 1
Softwares - Upgrades - Trendreader 1
 
Example of Application - Product
 
Pressure - Smartreader 1
Pressure-  Samrtreader 3
 
HVAC       - Smartreader 2
 
Temprature -Smartreader 2
Temprature -Smartreader 3
 
 
3/4/2010 11:45:37 AM
Bahram
Posts: 878
Joined: 12/8/2008
Location:Vancouver, BC Canada
Re: Building a Custom Master Detail Entity-Product in DSC
 
I see DSCCom.dbml, Product  and Manufacturer code  are in DSC Core Component ,  It seems  I need to add my code to relevant cs files and then build a new commercial core?
 
Is there any shortcut solution for not to touch CommercialCore,?
 
 
 
Thanks
3/4/2010 3:20:24 PM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: Building a Custom Master Detail Entity-Product in DSC
DSCCom.dbml is in the core component source code.
 
I don't see why you cannot create Category like Pressure or HVAC. Category is just a grouping tool. If you don't like these categories to be shown in the "CategoryList" block. You can filter out these in the code. And then use CategoryProducts block to show the products.
DotShoppingCart Staff
3/4/2010 4:39:04 PM
Bahram
Posts: 878
Joined: 12/8/2008
Location:Vancouver, BC Canada
Re: Building a Custom Master Detail Entity-Product in DSC
Then  I need to filter the existing Categories in New CategoryProducts Block.
 
So How can have an object of CategoryList Block based on this Filtered category
 
While I keep my current categoryList
 
3/5/2010 9:37:29 AM
Bahram
Posts: 878
Joined: 12/8/2008
Location:Vancouver, BC Canada
Re: Building a Custom Master Detail Entity-Product in DSC
 I was focused on  my solution, What is the code for filtering category  
3/5/2010 10:19:22 AM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: Building a Custom Master Detail Entity-Product in DSC
Here is more about my suggestion. Say you have CategoryA, CategoryB for the regular product categorization. Create a special Catagory named "OtherGrouping". And then put the sub groups e.g. Pressure, HVAC under that.
 
CategoryA
CategoryB
...
OtherGrouping
   -> Pressure
   -> HVAC
 
Look at method Page_Load in web\store\blocks\CategoryList.ascx.cs. Filter out the category "OtherGrouping" before the Databind() so that it won't display the category. Use CategoryProduct block to display the products in either Pressure or HVAC to any page that you like.
DotShoppingCart Staff
3/5/2010 12:01:00 PM
Bahram
Posts: 878
Joined: 12/8/2008
Location:Vancouver, BC Canada
Re: Building a Custom Master Detail Entity-Product in DSC
I filtered the Categories Named Parameters, with this code  The subcats are filtered, but the Parent Cat name Shows as the last Caregory : Parameters is the name of the Parent
 
foreach (Category c in categories)
            {
                if (true != c.DisplayName.ToString().Equals("Parameters", StringComparison.OrdinalIgnoreCase))
                    activeCategories.Add(c.CategoryId, true);
            }
 
How the parent categories will filter? since it is categories that goes to DataSource.
 
3/7/2010 10:54:02 PM
Bahram
Posts: 878
Joined: 12/8/2008
Location:Vancouver, BC Canada
Re: Building a Custom Master Detail Entity-Product in DSC
This is the Code :       
 
int ii = 0;
List<Category> removethis = new List<Category>();
 
for (ii = 0; ii < categories.Length ; ii++)
            if (true == categories[ii].DisplayName.ToString().Equals("Parameters", StringComparison.OrdinalIgnoreCase))
              removethis.RemoveAt(ii);
         else
              removethis.Add(categories[ii]);