There is a set of products in Drupal Commerce. How do I programmatically create a view that would select products for a particular field?
1 Answer
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.
-
2
-
2@ram4nd not quite repeat. Your answer lacked (and still lack) detailed info where to find export, and was poorly written (edited months after I posted mine).– MołotCommented Jan 28, 2016 at 9:00
-
That's usually where adding a comment comes in. Usually you only post another answer if there's something fundamentally different about what you're saying. Commented Jun 1, 2017 at 16:35
hook_views_default_views()
for altering an existing view whereas this Q (seems to be) about creating a View programatically from scratch.