Opencart 在模型中找不到自定义方法

Opencart can't found custom method in model

我在模型 php 中创建了一个名为 "getProductbySku" 的自定义方法。

/admin/model/catalog/product.php

public function getProductbySku($sku) {
        $query = $this->db->query("select id from " . DB_PREFIX . "product where sku = '".$sku."'");
        if($query->num_rows){
            return $query->row['product_id'];
        }else{
            return false;
        }
    }

/admin/controller/module/syncproduct.php

$this->load->model("catalog/product");
print_r(get_class_methods($this->model_catalog_product));
$product_id = $this->model_catalog_product->getProductbySku($row['sku']);
                if($product_id){
...

我无法调用我的方法。

致命错误:在第 204 行 public_html/admin/controller/module/syncproduct.php 中调用未定义的方法 ModelCatalogProduct::getProductbySku()

Array
(
    [0] => addProduct
    [1] => editProduct
    [2] => copyProduct
    [3] => deleteProduct
    [4] => getProduct
    [5] => getProducts
    [6] => getProductsByCategoryId
    [7] => getProductDescriptions
    [8] => getProductCategories
    [9] => getProductFilters
    [10] => getProductAttributes
    [11] => getProductOptions
    [12] => getProductOptionValue
    [13] => getProductImages
    [14] => getProductDiscounts
    [15] => getProductSpecials
    [16] => getProductRewards
    [17] => getProductDownloads
    [18] => getProductStores
    [19] => getProductLayouts
    [20] => getProductRelated
    [21] => getRecurrings
    [22] => getTotalProducts
    [23] => getTotalProductsByTaxClassId
    [24] => getTotalProductsByStockStatusId
    [25] => getTotalProductsByWeightClassId
    [26] => getTotalProductsByLengthClassId
    [27] => getTotalProductsByDownloadId
    [28] => getTotalProductsByManufacturerId
    [29] => getTotalProductsByAttributeId
    [30] => getTotalProductsByOptionId
    [31] => getTotalProductsByProfileId
    [32] => getTotalProductsByLayoutId
    [33] => __construct
    [34] => __get
    [35] => __set
)

所以,我将 "echo $file" 添加到 /system/engine/loader。php

public function model($model, $data = array()) {
    // $this->event->trigger('pre.model.' . str_replace('/', '.', (string)$model), $data);
    $model = str_replace('../', '', (string)$model);
    $file = DIR_APPLICATION . 'model/' . $model . '.php';
    echo $file;
...

没有任何变化... Opencart版本是2.1.0.1

此文件被覆盖 catalog/product 模型 system/modification/admin/model/catalog/product.php