added null check for main menu and dependent destroy for categories and sub-categories on products