Jump to content

Need SQL script that will put a price reduction on certain sub-categories.


Shaun

Recommended Posts

Does anyone out there use a SQL script that can be used to put certain categories, or sub-categories on sale for a certain amount of time? For example, if I wanted to reduce the price of Earrings by 10% for the month of October, how would I go about this? Also, how to put it back to how it was?
Please note, this is for price reduction, not "On Sale" as when the date has expired, the 'On Sale" box remains checked.

Link to comment
Share on other sites

Make a backup of your ps_product table, then try executing the following SQL query in phpMyAdmin:

UPDATE `ps_product` SET `reduction_percent` = 10, `reduction_from` = '2010-10-01 00:00:00', `reduction_to` = '2010-10-31 23:59:59' WHERE `id_category_default` = 2



Change ps_ to your database prefix and 2 to the ID of the Earrings category. Note that this SQL query relies on all "Earrings" products having the default category set to "Earrings".

Link to comment
Share on other sites

  • 2 weeks later...

Don't know what I'm doing wrong, but it's not working. I looked in the "ps_category_lang" table to see what the id for earrings was, in this case it is "8".
I then ran the

"UPDATE `ps_product` SET `reduction_percent` = 10, `reduction_from` = '2010-10-01 00:00:00', `reduction_to` = '2010-10-31 23:59:59' WHERE `id_category_default` = 8

query under the SQL tab for "ps_product".
The query looked like it ran fine, but said "O rows affected"?

Link to comment
Share on other sites

I was preparing screenshots to show you that I only have one default_category_id in my database when I think the light bulb went on (I attached them anyways).
There is only one value for default_category_id which is "1" for all ps_products. I checked all 32 pages of this and it is always the same. So, I checked the BO and see that I must have cheque marked all the products "home" and then cheque marked what category the product belonged to, that is why "1" is the default category for all products.
So, is there any way to target a category still and reduce the price, or is this a lost cause?

31182_NLDw5PojS9IX7v88iKUW_t

31184_7YA7nTgM0QxYejmvRWbC_t

31185_zHaGCiM7a0KLcDxw3cgp_t

31186_trriVvC2gQxi9BVElWM9_t

Link to comment
Share on other sites

You should change all your default categories from the "Home" category 1 to the ID of the subcategory they appear in, otherwise you will have to write a more complicated query. I'm not sure whether you can use LEFT JOIN in UPDATE queries. I've never tried it before.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...