Post by jlaframboise » Fri Feb 15, 2019 12:57 am

I have a few hundred products so I'd like to make a change to the database using sql but I have no idea how that's done. I want to change the subtract from stock value from 1 to 0.
Last edited by jlaframboise on Fri Feb 15, 2019 4:58 am, edited 1 time in total.

Newbie

Posts

Joined
Thu Dec 27, 2018 10:39 am

Post by straightlight » Fri Feb 15, 2019 2:35 am

Assuming it's for all your product option values, in your PHPMyAdmin, execute the following query:

Code: Select all

UPDATE `oc_product_option_value` SET `subtract` = '0' WHERE `subtract` = '1';
Note: Change oc_ prefix if using a different table prefix for your Opencart database. An additional note would be to consider that a web server can process a maximum range of 500 rows per queries when updating - also depending on the server's capacity.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by jlaframboise » Fri Feb 15, 2019 3:44 am

phpmyadmin doesn't let me paste this into the sql box. I tried to paste it to the query page but it disappears and doesn't do anything. I should have warned you, I'm not real bright.

No wonder people call me stupid. I was checking the wrong table. I also was able to paste using ctrl-v instead of right clicking on the mouse. Thanks a lot.
Last edited by jlaframboise on Fri Feb 15, 2019 4:57 am, edited 1 time in total.

Newbie

Posts

Joined
Thu Dec 27, 2018 10:39 am

Post by kestas » Fri Feb 15, 2019 4:40 am

straightlight wrote:
Fri Feb 15, 2019 2:35 am
Assuming it's for all your product option values, in your PHPMyAdmin, execute the following query:

Code: Select all

UPDATE `oc_product_option_value` SET `subtract` = '0' WHERE `subtract` = '1';
I do not understand why was suggested to make changes to product options table if question was
I have a few hundred products so I'd like to make a change to the database using sql but I have no idea how that's done. I want to change the subtract from stock value from 1 to 0.
I think you need to change just product table...
So you need In phpmyadmin paste the code above to sql field and click GO

Code: Select all

UPDATE `oc_product` SET `subtract` = '0' WHERE `subtract` = '1'

Custom OpenCart modules and solutions. You can write PM with additional questions... Extensions you can find here


Active Member

Posts

Joined
Tue Oct 12, 2010 2:23 am

Post by jlaframboise » Fri Feb 15, 2019 5:12 am

Thanks for your reply too kestas. Actually, I think I'll end up doing both. Everything was originally set to subtract from stock. The store owner wants to do that manually now so I had to change the existing values to 0. This value is set in two places, one on the data tab and the other on the options tab. I will also be setting the default to 0 or no but that is probably in one of the control pages. Thanks to both of you.

Newbie

Posts

Joined
Thu Dec 27, 2018 10:39 am

Post by straightlight » Fri Feb 15, 2019 5:52 am

kestas wrote:
Fri Feb 15, 2019 4:40 am
straightlight wrote:
Fri Feb 15, 2019 2:35 am
Assuming it's for all your product option values, in your PHPMyAdmin, execute the following query:

Code: Select all

UPDATE `oc_product_option_value` SET `subtract` = '0' WHERE `subtract` = '1';
I do not understand why was suggested to make changes to product options table if question was
jlaframboise wrote:
Fri Feb 15, 2019 5:12 am
Thanks for your reply too kestas. Actually, I think I'll end up doing both. Everything was originally set to subtract from stock. The store owner wants to do that manually now so I had to change the existing values to 0. This value is set in two places, one on the data tab and the other on the options tab. I will also be setting the default to 0 or no but that is probably in one of the control pages. Thanks to both of you.
Knowledge is everything, that's why.

@jlaframboise: You are going in the right direction. :)

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by paulfeakins » Fri Feb 15, 2019 5:32 pm

jlaframboise wrote:
Fri Feb 15, 2019 12:57 am
I'd like to make a change to the database using sql but I have no idea how that's done
Sounds dangerous, be sure to backup the database first.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom
Who is online

Users browsing this forum: No registered users and 386 guests