Drupal Commerce Blog

What's happening in the world of Drupal Commerce.

Quick and Dirty Price & Stock Updater with Editable Views

Have you ever wanted to be able to have a single page where you could update pricing and/or stock for your entire store? Look no further! Today you'll learn how to create a price and/or stock updater in 5 minutes with Views and the Editable Views module.

Create a new view

First, you will need to download the Editable Views module and enable it. We won't cover that here, but Drupal.org has a page on installing Drupal 7 modules that can walk you through the process. Once you do that, you will want to create a new view and set it up for our quick price updater page:

Make sure the view Show drop down to "Commerce Product" and set the Display format to "Editable table." You can name it whatever you would like, but in this particular case, I'm planning on adding a table to my Manage Product page, so the URL is set to "admin/commerce/products/quick-price-updater" to facilitate that. Once you're set, click "Continue & Edit" to go to the next step.

Add the proper fields

Now, you're going to want to add Title and SKU fields. Nothing special here. Once you do that, find the editable "Price (editable)" and (if you have Commerce Stock enabled) the "Stock (editable)" fields to your view as well. You'll need to add labels to them so that they show up in the table header. Once you've added those, rearrange accordingly.

Add a menu tab

Now, go ahead and add the menu tab so that your view will show up as a tab on the Manage Products page.

Check your work

Now would be a good time to check everything. Feel free to add some exposed filters or play around with the sorting to complete the page. Make sure you click Save and then click "View page" to see your handiwork.

Bask in the glow

All done! Your view should look something like this. There are a couple of things to note here:

  1. Editable Views are beta, so keep that in mind!
  2. Whenever you click "Save" on the Editable Views page, you will actually be saving everything on the page, regardless of whether or not you changed it. This could cause your site to drag considerably if you've got a lot of products and aren't paging the table.
  3. Formatting is a bit strange, hence the dirty part of this post!

Enjoy being able to edit prices on your products in a fraction of the time!

Nicholas Vahalik
Posted: Mar 31, 2014

Comments

nvahalik Nicholas Vahalik on June 11, 2015

Sorry for the year-late reply, here. But basically VBO doesn't really make it easy to do multiple field updates. With this method, you can update every field in the view. VBO would have you enter the information in after you select it.