Post by Acate » Thu Sep 02, 2010 9:02 pm

hi...is there a way to auto increment products prices in percent % ?

Newbie

Posts

Joined
Thu Sep 02, 2010 9:00 pm

Post by JAY6390 » Fri Sep 03, 2010 6:42 am

Do you mean increase the prices across a whole range of products?

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by Acate » Fri Sep 03, 2010 3:05 pm

e.g.
I have 400 products with a specific price.
Now my wholesale increased prices for all products.

Have I to increase all 400 products prices one by one?It's a hard long job!

So I'm looking for something that do this automaticaly for all products in stock.

Newbie

Posts

Joined
Thu Sep 02, 2010 9:00 pm

Post by mystifier » Fri Sep 03, 2010 4:40 pm

The easiest way is to run a very simple query on the database using, for example, phpmyadmin.

It would simply be something like:

UPDATE product SET price = (price * 1.05)

(product is the table name which would be slightly different if you specified a pre-fix such as oc_product)
Last edited by mystifier on Fri Sep 03, 2010 5:27 pm, edited 1 time in total.

Free v1.4.9 Extensions: Default Specials | Improved Search | Customer Activity Report | Customer Groups | Royal Mail With Handling | Improved Product Page | Random Products | Stock Report | All Products


User avatar
Active Member

Posts

Joined
Tue May 18, 2010 5:15 pm

Post by JAY6390 » Fri Sep 03, 2010 5:09 pm

My thoughts exactly, although I would also round up the prices too using CEIL on the price

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by mystifier » Fri Sep 03, 2010 5:27 pm

Price is defined as decimal(15,4) and formatted by currency so it should be okay but I guess

UPDATE product SET price = ROUND(price * 1.05, 2)

is cleaner, rounding to the nearest whole cent/penny.

Free v1.4.9 Extensions: Default Specials | Improved Search | Customer Activity Report | Customer Groups | Royal Mail With Handling | Improved Product Page | Random Products | Stock Report | All Products


User avatar
Active Member

Posts

Joined
Tue May 18, 2010 5:15 pm

Post by Acate » Fri Sep 03, 2010 5:37 pm

oh...very nice mod...
anyway why 1.05?

if I want to increase theme of 3%?

Newbie

Posts

Joined
Thu Sep 02, 2010 9:00 pm

Post by mystifier » Fri Sep 03, 2010 5:54 pm

It was an example. In your case, use 1.03 :)

It is not a mod; just a query to run on the database.

Free v1.4.9 Extensions: Default Specials | Improved Search | Customer Activity Report | Customer Groups | Royal Mail With Handling | Improved Product Page | Random Products | Stock Report | All Products


User avatar
Active Member

Posts

Joined
Tue May 18, 2010 5:15 pm

Post by JAY6390 » Fri Sep 03, 2010 6:05 pm

1.03 is 3%, 30% is 1.30
As for the rounding and formatting, mysql will take care of all that anyway (and it actually rounds it up when you put it in)

Code: Select all

mysql> INSERT INTO `tmp` VALUES ('5.0000');
Query OK, 1 row affected

mysql> SELECT num FROM `tmp`;
+-----+
| num |
+-----+
| 5   |
+-----+
1 row in set

mysql> 

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom
Who is online

Users browsing this forum: No registered users and 298 guests