Welcome Guest, Not a member yet? Register   Sign In
View product based on category and subcategory

i am developing a eCommerce site. In this I have Category and its Sub-category. Some Category have its Sub-category and Some Category have not its Sub-category. Example I have category of 'Mobile Phones' its have no Sub-category. and the Category 'Home Appliances'  have sub category like 'Freeze, Air Cooler' etc. I have view product page I want to view the product based on category if its has no subcategory . and  if the category have subcategory then I want to load its sub-category first after that I want to view the product based on the its sub-category not based on Category. In category table I have a column name 'addSubCat' that specifies the category has a sub-category or not. if the column value is 1 then it has subcategory and if it has 0 then no sub-category

There is no question here.

If you are asking how you deal with categories and sub categories, you can do this in several ways.

An easy way is just to check if there is a sub category or not. If there is, use that information in your view. If there is not, use the category information (if any - it is always possible that a product is not listed for a category or a sub category).

You do not need the 'has sub category' column. You lookup the category, then you look for subcategories. If none found it has no sub categories, if some found, then it has. I presume you have a category parent column so you know which parent a subcategory belongs to.


Theme © iAndrew 2016 - Forum software by © MyBB