Commerce - Edit Products via Plugin
This is a fairly complex question and this is only really a sketch of an answer.  

You'll want to get to know the available models and services in Commerce pretty well to achieve this in all.

You'll most likely do much more work in the plugin side of things than the template side of things - that is, you'll pull together the models/data you want in the plugin, and then pass those things through to the template, rather than just retrieve the data in the template I'd say (as per your example there).

You'd take the various selection paramaters (categories, stock level, whatever) and post these to a controller in your plugin. Then in your plugin, you'd get the variant models you want via PHP, and then post this data through to a template that would render it into a form, and probably just return this whole form via json as some html that you then display with some front end ajax

         $this-&gt;requirePostRequest();
         $param1 = craft()-&gt;request-&gt;getPost('whatever'));              

        //This is a service in your plugin that gathers and returns variant models
        $data = craft()-&gt;yourplugin-&gt;searchStock($param1,...);


       $html = $this-&gt;renderTemplate('yourplugin/stockEditForm', array(
            'products' =&gt; $data,
        ), true);

        $this-&gt;returnJson(["success"=&gt;true, "html"=&gt;$html]);


... in your stockEditForm you then just loop through the products as normal

       {% for product in products %} ...etc


... then some ajax to actually render that on the plugin page

        $.ajax({
        type: 'POST',
        url: '/actions/yourplugin/bulkStockEdit',
        data: form_data,
        success: function(response) {
            $spinner.hide();
            $results.html(response.html);
            $results.show();
        },
        statusCode: {
            500: function(jqXHR, textStatus, errorThrown) {
              $spinner.hide();
              $results.html(jqXHR.responseText);
              $results.show();
            }
        },
    });


That will get you a form with the data populated into it.  From there, each save button in your constructed will need to be hooked up to some ajax to call appropriate Commerce controllers to actually save the changed variants... 

I think that, as a basic structure, would get you going with this.  Bulk stock editing certainly would be handy at times!