Jump to content

[Solved] Mass Update All The Products


Recommended Posts

Hi to all,

I am running on PS 1.4.9.0.

I have inserted all my products, 3k by now and marked this option: "When out of stock: Allow orders"

I would like to change for all of them to: When out of stock: Default: Deny orders (as set in Preferences)"

Do you think there is a smart way of doing it, or should I enter each product and change it?

Huge thanks for your support

 

Happy selling.

Proud PS user

Edited by CleanDev.eu (see edit history)
Link to comment
Share on other sites

You can do it with SQL database manager like PHPMYADMIN

you need to write sql request which will change the ps_product table and field available_for_order to '0' when quantity < out_of stock :) feel free to write if you've got questions

would there be any chance that you could write such a sql query for me?

Huge thanks in advance

Link to comment
Share on other sites

You can do it with SQL database manager like PHPMYADMIN

you need to write sql request which will change the ps_product table and field available_for_order to '0' when quantity < out_of stock :) feel free to write if you've got questions

I have managed to connect Oracle SQL Developer to my MySQL DB using (mysql-connector-java)

What I can see is that in field "out_of_stock" I have only (1 and 2) and in field "available_for_order" all are "true" for me.

As I am not a programer, and I know nothing about databases, I will need the support from the community with such a task.

I have managed to build a select, but I am not sure I can go further:

SELECT * FROM ID_PRODUCT

WHERE available_for_order like 'true';

Huge thanks for your time

Link to comment
Share on other sites

You can do it with SQL database manager like PHPMYADMIN

you need to write sql request which will change the ps_product table and field available_for_order to '0' when quantity < out_of stock :) feel free to write if you've got questions

I have tried it again, here is what I have but it is not good.

There are 2 reasons, first is that if the commands would work, but it does not, I receive a syntax error, I will only make unavailable for order the products that are at the moment with stock 0, but I will need to run this after each order is placed.

 

SELECT * FROM `ps_product`

WHERE `quantity` = '0'

SELECT REPLACE(available_for_order, '1', '0');

Edited by CleanDev.eu (see edit history)
Link to comment
Share on other sites

  • 1 year later...

Hi,

 

I have all my products with Available for order = 0, that doesn't allow any product to add to cart.

 

I want to set Available for order = 1, It is very hard to go in all products and update them.

I tried using MYSQL Query on ps_product table to update available_for_order field, it was updated also but in back-end still the check-box is unchecked for all products.

 

If I try using manual update it works fine.

 

Can any one help me on this?

 

Thanks,

Link to comment
Share on other sites

  • 1 month later...

Hi,

 

I have all my products with Available for order = 0, that doesn't allow any product to add to cart.

 

I want to set Available for order = 1, It is very hard to go in all products and update them.

I tried using MYSQL Query on ps_product table to update available_for_order field, it was updated also but in back-end still the check-box is unchecked for all products.

 

If I try using manual update it works fine.

 

Can any one help me on this?

 

Thanks,

hi.

i use your code and I had the same problem and I solved it.

It is very easy

just repet your query for ps_product

 

in total:

 

UPDATE `ps_product_shop` SET available_for_order =1

UPDATE `ps_product` SET available_for_order =1

Thanks from all,

Link to comment
Share on other sites

  • 1 year later...

Hi all. You could use this function example:

<?php
function deny_order() {
	include_once '../config/config.inc.php';
	include(dirname(__FILE__).'/init.php');
	
	ini_set('display_errors',0);
	error_reporting(E_ALL & ~E_NOTICE);

	$defaultLanguage = new Language((int)(Configuration::get('PS_LANG_DEFAULT')));
	$languages = Language::getLanguages();
	$lang_id = $defaultLanguage->id;

	$id_product = "8349";

	$sql = 'UPDATE '._DB_PREFIX_.'stock_available SET out_of_stock = 0 WHERE id_product ='.$id_product.'';
	$set_up = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
}

I use it for specific product targeting and it can be accessed through another function that selects for example all the products from a specific manufacturer or supplier or... you name it.

$id_product = array();
$sql = 'SELECT id_product FROM '._DB_PREFIX_.'product WHERE id_supplier = 1 and id_manufacturer = 3';
$id_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);

if ($id_product) {
	foreach ($id_product as $key => $value) {
		deny_order($value['id_product']);
	}
}

In that case of course, the "deny_order" function will have the $id_product parameter commented inside the function and given as a key: function deny_order($id_product). 

 

I know this is straight forward for most people reading this but I mention it for beginners mainly (as myself).

Edited by tony_mik (see edit history)
Link to comment
Share on other sites

  • 3 months later...

 

 

 

When out of stock

Deny orders

Allow orders

Default: Allow orders as set in the Products Preferences page

 

Hi, I want to set with a sql query the "default" value for all items. I can not understand this setting in which field !

I am going crazy !

 

 

You should use Prestashop functions at all time - I found out that the hard way.

For that, you must create a PHP file, inside which you put a function that takes all the products from your store, goes through every single one and updates the stock order option you want.

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...