Question: One of the core files **classes/stock/StockAvailable.php** contains:

```
class StockAvailableCore extends ObjectModel
{
   public static function getQuantityAvailableByProduct($id_product = null, $id_product_attribute = null, $id_shop = null)
     {
       ...
     }
  ...
}

```

I want to call this **getQuantityAvailableByProduct()** method from my module.

So I tried to include this class (and it's father class and father's interface), extend it and call method like this:

```
require_once('../../src/Core/Foundation/Database/EntityInterface.php');
require_once('../../classes/ObjectModel.php');
require_once('../../classes/stock/StockAvailable.php');

$MyClass = new StockAvailableCore();

$MyClass->getStockAvailableIdByProductId($id);

```

And the error that I'm getting:

```
PHP Fatal error:  Uncaught Error: Class 'ObjectModel' not found in /home/mantas/Server/honey/classes/stock/StockAvailable.php:34

```

What am i missing? And is this the correct way to extend a class and call method?

Answer: 
I see two choices:

1. Using a Ubuntu image, leave the Python from system untouched. Install pyenv (<https://github.com/pyenv/pyenv>), then download a python 3.7 install, completely separated from system's Python.

or

2. Use the official Python image labeled 3.7.3-stretch or 3.7.3-slim-stretch (Debian)
The solution by @donhector has two subtle problems:

1. It will only install the outdated version 3.7.5 of Python. You need the repo `ppa:deadsnakes` to get newer versions
2. By installing alternatives for `python` it breaks the convention that `python` is used for Python 2.x. This might break apt, see [How to update-alternatives to Python 3 without breaking apt?](https://stackoverflow.com/questions/43062608/how-to-update-alternatives-to-python-3-without-breaking-apt)

A solution without these problems is:

```
FROM ubuntu:18.04

# Upgrade installed packages
RUN apt update && apt upgrade -y && apt clean

# install python 3.7.10 (or newer)
RUN apt update && \
    apt install --no-install-recommends -y build-essential software-properties-common && \
    add-apt-repository -y ppa:deadsnakes/ppa && \
    apt install --no-install-recommends -y python3.7 python3.7-dev python3.7-distutils && \
    apt clean && rm -rf /var/lib/apt/lists/*

# Register the version in alternatives (and set higher priority to 3.7)
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 2

# Upgrade pip to latest version
RUN curl -s https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \
    python3 get-pip.py --force-reinstall && \
    rm get-pip.py

```