Answers for "call a controller other than the controller in opencart"

PHP
1

call a controller other than the controller in opencart

//controller
$data['api_key_post'] = (!empty($this->load->controller('product/api_product', $product_id))) ? $this->load->controller('product/api_product', $product_id) : '';


// new controller

<?php

class ControllerProductApiProduct extends Controller
{
    public function index($id)
    {
        $this->load->model('catalog/apikeypostavshik');
        return $this->model_catalog_apikeypostavshik->getSupplierId($id);
    }
}


//Model 

<?php

class ModelCatalogApiKeyPostavshik extends Model
{
    public function getSupplierId($product_id)
    {
        $query = $this->db->query("SELECT `api_key` FROM `" . DB_PREFIX . "neoseo_suppliers` WHERE `id` IN (SELECT supplier_id from oc_neoseo_suppliers_products where product_id = '" . (int)$product_id . "')");

        return $query->row['api_key'];
    }

}
Posted by: Guest on October-21-2021

Code answers related to "call a controller other than the controller in opencart"

Browse Popular Code Answers by Language