Jump to content

override StockAvailable function getQuantityAvailableByProduct


Recommended Posts

Hi, I'm having problems with the override of stockAvailable function getQuantityAvailableByProduct.
I take quantity from a webservice, the GET it done correctly and I see the quantity in the product but when I clickt in  add to cart Nothing happens. I know I'm killing something but I do not know it's
 
class StockAvailable extends StockAvailableCore
{
 
    public static function getQuantityAvailableByProduct($id_product = null, $id_product_attribute = null, $id_shop = null)
    {
 
....
$ch=curl_init($url);
....
$stock = json_decode($ch);
$cantidadStock = (int)$stock->stock;
curl_close($ch);
...
return $cantidadStock;
 
    }
    
}

 

 

Link to comment
Share on other sites

Hi Zorrobsas

Try to make an override for all functions and modify only that you need to edit. I mean...

  1. Copy the StockAvailable.php original class file
  2. Paste into the override/classes/stock/ folder
  3. Modify the class and extend from the core
  4. Edit the function that you need

In some cases, it works.

 

I hope this can be useful.

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

 
Hi, I found the error. It did not work for me in one of the loop that calls the function for idproduct at zero. Who can help me?
 
 
class StockAvailable extends StockAvailableCore
{
    public static function getQuantityAvailableByProduct($id_product = null, $id_product_attribute = null, $id_shop = null)
    {
    PrestaShopLogger::addLog(' Class over', 1, null, 'over', (int)$id_product, true);
    return 1000; 
    }
}

Hi, I found the error. It did not work for me in one of the loop that calls the function for idproduct at zero. Who can help me?

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

  • 5 years later...

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