How do I programmatically create a view? There is a set of products in Drupal Commerce. How do I programmatically create a view that would select products for a particular field?
The classic way is to create it manually, via UI, then click "export" (path like http://example.org/admin/structure/views/view/default_demo/export), and wrap resulting code into a module using hook_views_default_views(), maybe fine-tuning details.