Q:

Opencart 2.2.0 define stock status ID

Even though I am somewhat embarrassed to ask this question, here it is. I am trying to define $stock_status_id variable in my controller file which I will echo in my tpl afterwords. I set in controller file as  'stock_status_id' => $result['status_stock_id'],but it gives me the 

Undefined index 'stock_status_id' error

. Normally, this would be enough, as it was with other variables I defined. What am i doing wrong here? The stock_status_id field exists in oc_product table. My entire controller file is as following:
  <?php
class ControllerModuleDobavljivi extends Controller {
    public function index($setting) {
        $this->load->language('module/dobavljivi');
        $data['logged'] = $this->customer->isLogged(); 
        $data['heading_title'] = $this->language->get('heading_title');
        $data['customer_group_id'] = $this->customer->getGroupId();

        $data['text_tax'] = $this->language->get('text_tax');

        $data['button_cart'] = $this->language->get('button_cart');
        $data['button_wishlist'] = $this->language->get('button_wishlist');
        $data['button_compare'] = $this->language->get('button_compare');

        $this->load->model('catalog/product');

        $this->load->model('tool/image');

        $data['products'] = array();

        $filter_data = array(
            'sort'  => 'p.stock_status_id',
            'order' => 'DESC',
            'start' => 0,
            'limit' => $setting['limit']
        );

        $results = $this->model_catalog_product->getProducts($filter_data);

        if ($results) {
            foreach ($results as $result) {
                if ($result['image']) {
                    $image = $this->model_tool_image->resize($result['image'], $setting['width'], $setting['height']);
                } else {
                    $image = $this->model_tool_image->resize('placeholder.png', $setting['width'], $setting['height']);
                }

                if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
                    $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
                    $wholesale = $this->currency->format($this->tax->calculate($result['wholesale'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
                } else {
                    $price = false;
                    $wholesale = false;
                }

                if ((float)$result['special']) {
                    $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
                } else {
                    $special = false;
                }

                if ($this->config->get('config_tax')) {
                    $tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price'], $this->session->data['currency']);
                } else {
                    $tax = false;
                }

                if ($this->config->get('config_review_status')) {
                    $rating = $result['rating'];
                } else {
                    $rating = false;
                }

                $data['products'][] = array(
                    'product_id'  => $result['product_id'],
                    'thumb'       => $image,
                    'name'        => $result['name'],
                    'stock_status_id' => $result['status_stock_id'],
                    'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get($this->config->get('config_theme') . '_product_description_length')) . '..',
                    'price'       => $price,
                    'wholesale'   => $wholesale,
                    'special'     => $special,
                    'tax'         => $tax,
                    'upc'       => $result['upc'],
                    'rating'      => $rating,
                    'href'        => $this->url->link('product/product', 'product_id=' . $result['product_id'])
                );
            }

            return $this->load->view('module/dobavljivi', $data);

        }
    }

}

Thanks.

A:

In your product model, make sure you are fetching stock_status_id in getProducts($data = array()), then it will return expected result.

