Byte Webdesign Posted July 14, 2017 Share Posted July 14, 2017 (edited) Hello!Is it possible to change the default product quantity when adding a new product?My client buys most products in bulk so it would save alot of time. The shop is using PS: 1.6.1.13Thanks in advance!Regards,Frank Edited July 15, 2017 by Byte Webdesign (see edit history) Link to comment Share on other sites More sharing options...
musicmaster Posted July 15, 2017 Share Posted July 15, 2017 Your link doesn't work. I get a "you don't have permission for this" error. Link to comment Share on other sites More sharing options...
Byte Webdesign Posted July 15, 2017 Author Share Posted July 15, 2017 Was a link to another post on this forum: https://www.prestashop.com/forums/topic/518476-default-quantity-1-when-adding-new-product/I tried that solution but it doesn't work for me, some help would be appreciated! Link to comment Share on other sites More sharing options...
musicmaster Posted July 15, 2017 Share Posted July 15, 2017 I haven't tested it but I think that something like the following should work: In the add() function in Product.php near the end you have the following code: foreach ($id_shop_list as $value) StockAvailable::setProductOutOfStock((int)$this->id, 2, $value); That should become something like foreach ($id_shop_list as $value) { StockAvailable::setProductOutOfStock((int)$this->id, 2, $value); StockAvailable::updateQuantity((int)$this->id, 0, $quantity, $value); } Note that the zero stands for id_product_attribute. If your products have attributes you will need to do something with that. Link to comment Share on other sites More sharing options...
Byte Webdesign Posted July 15, 2017 Author Share Posted July 15, 2017 (edited) Hello Musicmaster,First of all thanks for the quick reply! I have added the mentioned code but sadly it still adds new product with a quantity of 0 public function add($autodate = true, $null_values = false) {if (!parent::add($autodate, $null_values)) {return false;}$id_shop_list = Shop::getContextListShopID();if ($this->getType() == Product::PTYPE_VIRTUAL) {foreach ($id_shop_list as $value) {StockAvailable::setProductOutOfStock((int)$this->id, 1, $value);}if ($this->active && !Configuration::get('PS_VIRTUAL_PROD_FEATURE_ACTIVE')) {Configuration::updateGlobalValue('PS_VIRTUAL_PROD_FEATURE_ACTIVE', '1');}} else {foreach ($id_shop_list as $value) {StockAvailable::setProductOutOfStock((int)$this->id, 2, $value);StockAvailable::updateQuantity((int)$this->id, 0, $quantity, $value);}}$this->setGroupReduction();Hook::exec('actionProductSave', array('id_product' => (int)$this->id, 'product' => $this));return true;} Edited July 15, 2017 by Byte Webdesign (see edit history) Link to comment Share on other sites More sharing options...
musicmaster Posted July 15, 2017 Share Posted July 15, 2017 And where did you add your quantity? It was meant that you replaced "$quantity" with your number. BTW: do you have development mode enabled? You should have gotten an error message for an undefined variable. Link to comment Share on other sites More sharing options...
Byte Webdesign Posted July 16, 2017 Author Share Posted July 16, 2017 I do have dev mode enabled indeed and didn't get an error message.I tried to define $quantity and did get an error message then. But just changing $quantity with a number did the trick! Problem solved, thanks Musicmaster Link to comment Share on other sites More sharing options...
musicmaster Posted July 17, 2017 Share Posted July 17, 2017 I do have dev mode enabled indeed and didn't get an error message. I tried to define $quantity and did get an error message then. But just changing $quantity with a number did the trick! Problem solved, thanks Musicmaster I am glad you solved this. Note that a missing value is a warning, not an error. So it generates a message but then the rest of the page will be generated. At most you will see that the header of your webpage is a bit misformed. However, if you select to see the page source in your browser you will see the message (search for words like error and warning). Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now