Jump to content

Require Product Weight.


mytheory.

Recommended Posts

HI,

We want to move from price-based shipping costs to weight-based. I have 3 questions regarding this matter:

1) In the BO, when entering the product information is there a way to require the employee to enter a weight at least greater than 0? To eliminate any mistakes when we switch over, we want there to be an error sign when they save if this field is not correctly filled out.

2) What SQL query must I use if I want update all the weights of the main products that are already in the DB? Since we've been using price-based calculations all the weight fields for all our products are set to zero... so instead of manually updating 1000's of products, there must be a query that does this right? We want to keep attribute weights at zero... just the weights for the main product (which I assume would update with the quantity).

3) Might be an obvious question... but the weight field is inputted by lb. (considering this is how our localization is set to). So for example, half a pound would go in as .5 right instead of say 8 ounces...??

Thanks!

Link to comment
Share on other sites

1) Edit classes/Product.php and change line 156 (in PrestaShop v1.3.5) from:

protected $fieldsRequired = array('id_tax', 'quantity', 'price');



to:

protected $fieldsRequired = array('id_tax', 'quantity', 'price', 'weight');



This should make the weight a required field.

2) Use something like this:

UPDATE `ps_product` SET `weight` = 100 WHERE `id_product` = 1;
UPDATE `ps_product` SET `weight` = 200 WHERE `id_product` = 2;



You should be able to write a big SQL query to update individual product weights this way.

3) Yes, that's right.

Link to comment
Share on other sites

I think there might be a foreach loop, but I always use Boolean expressions in the WHERE clause, or remove it altogether to set the same weight to every product. You could use WHERE `id_product` >= 1 AND `id_product` <= 100 to set products 1 to 100 to the same weight.

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