Jump to content

Error - Cannot redeclare class StockAvailableCore


Recommended Posts

Hi.

 

I'm having trouble to use the StockAvailableCore class... i'm developing a module which needs to change some product's stock quantity... 

 

At the first line of my module, i put the code

    public function __construct(){                          
        StockAvailableCore::updateQuantity(1, null, -1,null);
        exit();

But i'm receiving the error

 

Fatal error: Cannot redeclare class StockAvailableCore

in PS_PATH\classes\stock\StockAvailable.php on line 813

 

The code above is at the first line of my constructor, so i can't be including the class by myself...

 

And this error only appears when displaying a page that is on some tab of my module... on the "modules" tab, for example, the code works fine.

 

Inspecting the StockAvailable class, i noticed that  the code runs fine until the line below:

public static function updateQuantity($id_product, $id_product_attribute, $delta_quantity, $id_shop = null)
	{
		//debug message
                 echo 0;
		if (!Validate::isUnsignedId($id_product))
			return false;

                //debug message
		echo 2;
		$id_stock_available = StockAvailable::getStockAvailableIdByProductId($id_product, $id_product_attribute, $id_shop);

And when calling the getStockAvailableIdByProductId function, the program throws the error... The function isn't executed.

 

How may i fix this error?

 

Thanks in advance.

Link to comment
Share on other sites

×
×
  • Create New...