Discussions

update multiple prices

Hi,

I am making a shop with multiple product variations resulting in maybe thousands of products. I have looked at VBO to update prices but it seems that I still need to click save on each single price update?

1. What is the recommended method for updating many different prices?

2. Is there a method where I eventually can calculate the productprice based on some product-properties?

Regards
Lars Nielsen / Grafikom

Posted: Apr 2, 2012

Comments

larsmw on April 3, 2012

I have been looking at VBO (Views Bulk Operations) to assist commerce and now I can edit around 20-30 prices on a page. But I still have to click 'save' on each single value!

Are there any spreadsheet-like procedures to update multiple prices?

ñull on July 18, 2012

In Ubercart I could apply a query directly to MySQL and update prices by multiplying or adding. Now that everything has become field based, it has become very complex to find the right query. Anybody has tried it in Commerce that could share his experience?

wthem on October 25, 2012

For me worked the solution mentioned by pcambra. I have installed the module http://drupal.org/project/editablefields, then gone to admin/commerce/products (of course http://drupal.org/project/commerce_vbo_views is required), edited the view of product list (upper right corner, engine gear icon), clicked the "Commerce Product: Price (Price)", set the formatter to "editable". After this, I was able to edit all prices without editing and saving the product itself.

Strompf on June 8, 2018

The quick-and-dirty method to directly update the database in Übercart, is still possible in Drupal Commerce. However, it became a lot less quick and a lot more dirty - Only use this if you know what you are doing; not recommended as a general method.

In this example, all prices are increased with 10%:

##########################################
# Update field
##########################################

# Test
###############
#
# select
#
#     field_data_commerce_price.commerce_price_amount,
#     commerce_product.product_id,
#     commerce_product.revision_id,
#     commerce_product.sku,
#     commerce_product.title
#    
# from field_data_commerce_price
# join commerce_product on field_data_commerce_price.entity_id = commerce_product.product_id
#
# where type like "product";

# Update
#########
#
update field_data_commerce_price
join commerce_product on field_data_commerce_price.entity_id = commerce_product.product_id

set field_data_commerce_price.commerce_price_amount = 1.1* field_data_commerce_price.commerce_price_amount

where type like "product";

##########################################
# Update revision
##########################################

# Test
##############
#
# select
#
#     field_revision_commerce_price.commerce_price_amount,
#     commerce_product.product_id,
#     commerce_product.revision_id,
#     commerce_product.sku,
#     commerce_product.title
#    
# from field_revision_commerce_price
# join commerce_product on field_revision_commerce_price.entity_id = commerce_product.product_id
#
# where type like "product";

# Update
########
#
update field_revision_commerce_price
join commerce_product on field_revision_commerce_price.entity_id = commerce_product.product_id

set field_revision_commerce_price.commerce_price_amount = 1.1* field_revision_commerce_price.commerce_price_amount

where type like "product";