在MVC架构中,一个数据模型Model的作用就是针对数据库提取或保存数据。在控制器controller获得或将数据提交给数据模型Model时,需要先加载此特定的数据模型。
加载数据模型Model: $this->load->model('catalog/product');
从数据模型获取数据: $this->model_catalog_product->getTotalProducts()
提交数据给数据模型: $this->model_catalog_product->editProduct()
$this->load->model('catalog/product') 告诉opencart在网站后台admin或网站前台catalog中加载该数据模型Model (model/catalog/product.php)。 getTotalProducts(), editProduct() 是数据模型 model/catalog/product.php 中的两个函数。
打开文件 model/catalog/product.php 并找到 public function getProduct.
See list after return array, and you will found all product data.
The question is, if the getProduct() listed all product data, why it doesn't show at category page (frontpage)? This because the category controller decide not to show all data.
Open controller/product/category.php, find $this->data['products'][] = array to see what product data is used by controller.