If this is your first visit, check our documentation. To post, register or login.
Forums / Setting Up Categories, Products, Attributes / SQL code to populate a wholesale column as a percentage of the product price.

SQL code to populate a wholesale column as a percentage of the product price.

Started by ilmarchez on 17 Jul 2015, 7:32 PM · Views: 767

Results 1 to 4 of 4
17 Jul 2015, 7:32 PM
#1
ilmarchez avatar

ilmarchez

Zen Follower

Join Date:
Aug 2009
Posts:
128
Plugin Contributions:
0

SQL code to populate a wholesale column as a percentage of the product price.

Hi,

I have installed the addon "Dual Pricing" so now my table "products" as two columns:

  • "products_price"
  • "products_price_w"

The column "products_price_w" is empty. for new products I'll set manually from the product admin the wholesale price, but I'd like to populate the "products_price_w" column for all the thousands of products I already have listed with a value calculated as 90% of the "products_price" (so all wholesale prices are discounted by 10%).

Could you please tell me the SQL Query to populate the "products_price_w" as 90% value of "products_price"?
It is an one time operation.

Thank you very much.

17 Jul 2015, 8:08 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: SQL code to populate a wholesale column as a percentage of the product price.

ilmarchez:

Hi,

I have installed the addon "Dual Pricing" so now my table "products" as two columns:

  • "products_price"
  • "products_price_w"

The column "products_price_w" is empty. for new products I'll set manually from the product admin the wholesale price, but I'd like to populate the "products_price_w" column for all the thousands of products I already have listed with a value calculated as 90% of the "products_price" (so all wholesale prices are discounted by 10%).

Could you please tell me the SQL Query to populate the "products_price_w" as 90% value of "products_price"?
It is an one time operation.

Thank you very much.

Backup database before performing. Use tools->install SQL patches from the admin panel.

UPDATE products SET products_price_w = (0.9 * products_price);

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

17 Jul 2015, 9:46 PM
#3
ilmarchez avatar

ilmarchez

Zen Follower

Join Date:
Aug 2009
Posts:
128
Plugin Contributions:
0

Re: SQL code to populate a wholesale column as a percentage of the product price.

mc12345678:

Backup database before performing. Use tools->install SQL patches from the admin panel.

UPDATE products SET products_price_w = (0.9 * products_price);


Perfect, thank you!
17 Jul 2015, 9:57 PM
#4
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: SQL code to populate a wholesale column as a percentage of the product price.

ilmarchez:

Perfect, thank you!

Glad to get some code right today... :) Glad it worked for you too.. :) Good luck!

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...