Jump to content

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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 by Byte Webdesign (see edit history)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More